在 google colab 中保存 pip 安装

Saving pip installs in google colab

有没有办法将 Google Collab 中的包保存到我的 Google 驱动器?这样一来,我就不必在每次要使用它们时都重新下载和重新安装它们了。

要将安装的配置保存到 Google 驱动器:

from google.colab import drive
drive.mount('/content/gdrive')
pip freeze --local > /content/gdrive/My\ Drive/colab_installed.txt

要从驱动器恢复:

from google.colab import drive
drive.mount('/content/gdrive')
pip install --upgrade --force-reinstall `cat /content/gdrive/My\ Drive/colab_installed.txt`