Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving pip installs in google colab

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.

like image 927
Dr. Fontaine Avatar asked Sep 30 '18 23:09

Dr. Fontaine


People also ask

Can you pip install in Google Colab?

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

How do I permanently mount Google Drive in Colab?

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.

Can you save files in Google Colab?

Working with Google SheetsColab allows you to save your work to Google Drive or even directly to your GitHub repository.


1 Answers

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`
like image 78
Bob Smith Avatar answered Nov 15 '22 09:11

Bob Smith