Is there a way to save packages in Google Collab to my Google Drive? This is so I won't have to re-download and re-install packages every time I want to use them.
All you need to do is to use pip install within the notebook. However, all this fails if you are working with private packages. That is, a package that you are developing on a private repository hosted on a versioning service (e.g. GitHub).
Then navigate to the file browser. Click on "Mount Drive". From then on, every time I connect, it automatically mounts Drive during the Initializing phase. Save this answer.
Working with Google SheetsColab allows you to save your work to Google Drive or even directly to your GitHub repository.
To save your the installed configuration to your Google Drive:
from google.colab import drive
drive.mount('/content/gdrive')
pip freeze --local > /content/gdrive/My\ Drive/colab_installed.txt
To restore from drive:
from google.colab import drive
drive.mount('/content/gdrive')
pip install --upgrade --force-reinstall `cat /content/gdrive/My\ Drive/colab_installed.txt`
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