How to install python dependencies using a requirements file in Google Colab?
Like the equivalent of pip install -r requirements.txt
The accepted answer is indeed correct, you will need to install your packages to the virtual machine every time you run it.
To import a library that's not in Colaboratory by default, you can use !pip install or ! apt-get install .
With Daniel's hint above, I was able to solve it.
Using the "uploading files from local computer script" I uploaded my requirements.txt file onto Google Colab platform. Script is found here. This is the script,
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
The output on executing, clearly says that, it is saving this file as 'requirements.txt'. I couldn't however find this file in Google Drive, which is fine by me. Then,
!pip install -r requirements.txt
worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With