Google colab can not find an installed package
Table of Contents
Issue
I want to use my custom package in Google colab. I installed my package and other packages that are required.
But, when I import a package, let's say logzero
, Google colab says “Module Not Found Error”
My environment
Google colab Pro+ at the date 2022/10/29
My custom package is able to be built with poetry.
Check list
- The package installation is successful.
- I run
python -m pip list | grep logzero
. Yes, logzero is surely installed. - I run
python -m pip install logero -U
. Nothing changes.
Solution
The following procedure was correct.
- generating
requirements.txt
with poetry. - running
!pip install -r requirements.txt
in the Google Colab interface.
Here are the commands.
1 2 3 |
# use pip install -r requirements.txt, instead !cd /content/my-package && make clean && poetry export -f requirements.txt --output requirements.txt !cd /content/my-package && pip install -r ./requirements.txt |
What was the reason?
Unknown. But, Google colab's jupyter kernel may not recognize packages installed by python setup.py install
.
Discussion
New Comments
No comments yet. Be the first one!