GMRK
May 20, 2024, 12:25pm
1
Good day everyone,
I am trying to run pyodk script(s) on Google Colab, and getting this error:
ModuleNotFoundError Traceback (most recent call last)
in <cell line: 5>()
3 from pathlib import Path
4
----> 5 from pyodk.client import Client
6 from pyodk.errors import PyODKError
7 from requests import Response
ModuleNotFoundError: No module named 'pyodk'
What could be the problem?
The main issue is when i run the line "from pyodk.client import Client".
You'll need to install pyodk first in your notebook. Put this in the first cell of the notebook.
!pip install pyodk
GMRK
May 20, 2024, 7:44pm
3
Good day, Thank for helping. I tried '!pip install pyodk' at the beginning of Colab, but i get this error:
It works for me.
Did you create your config and cache files? Maybe try a fresh notebook.
GMRK
May 21, 2024, 7:02am
5
No, I did not create config and cache files. How do we do that?
I tried with a new notebook and I am still getting the same problem.
LN
May 21, 2024, 5:43pm
6
The error in red suggests that something is installing an old version of the requests
library. Can you try removing your explicit import on requests
and see whether that works?
GMRK
May 21, 2024, 6:28pm
7
Using python code? Would you mind sharing the commands for that?
Thanks
LN
May 21, 2024, 7:36pm
8
The screenshot you shared has from requests import Response
. Could you try removing that?
GMRK
May 22, 2024, 5:39pm
10
Thanks, this helped. Although i had to use %pip install pyodk. I hope this won't give me issues. Because I am getting this error: "ERROR:pyodk._utils.config:Cached token not found in file: pyodk_cache.toml
NoneType: None", which doesn't seem cause any problem because I am able to query Central API.
I think Google Colab file systems aren't persistent, so you'll want to store the pyodk_cache and pyodk_config on Google Drive.
https://stackoverflow.com/a/63484269 has some examples of how to do that.