ModuleNotFound running pyODK on Google Colab

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
----> 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

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.

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.

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?

Using python code? Would you mind sharing the commands for that?


The screenshot you shared has from requests import Response. Could you try removing that?

  1. Click on the Folder icon to go into the files view.
  2. Right-click in the space below the sample_data folder. It will bring up a menu. Select New file.
  3. Create a new file called pyodk_cache.toml. Create another called pyodk_config.toml
  4. Double-click pyodk_config.toml and put the configuration described at
    base_url = ""
    username = "my_user"
    password = "my_password"
    default_project_id = 123
  5. Now, adjust your Client() call in your source code to point to the files
    client = Client(config_path="pyodk_config.toml", cache_path="pyodk_cache.toml")```

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. has some examples of how to do that.