问题
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.
回答1:
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 google.colab import drive
drive.mount('/content/gdrive')
pip install --upgrade --force-reinstall `cat/content/gdrive/My\ Drive/colab_installed.txt`
来源:https://stackoverflow.com/questions/52582858/saving-pip-installs-in-google-colab