Google Colab (Jupyter Notebook): Install and import a package from Google Drive

Viewed 49

I want to install and import a package (that I created myself and which is not public) from a google drive into a jupyter notebook. The package works locally and can be imported and used.

Installing the package via jupyter magic works:

%pip install /content/drive/MyDrive/mypackage/
[...]
Successfully installed mypackage

It completes after successfully installing the package and its dependencies.

But when I try to import the package:

import mypackage
ModuleNotFoundError: No module named 'mypackage'

pip freeze shows the dependency but it does not show the package version, but its path: mypackage @ file:///content/drive/MyDrive/mypackage. Even if I add that path to the sys.path, it does not work.

I am using the free version of Colab, if that matters ( but could upgrade).

What I am doing wrong and what can I do to fix it?

0 Answers
Related