如何在Google Colab中使用需求文件安装python依赖项?
就像pip install -r requirements.txt
的等价物
发布于 2018-05-17 05:30:00
有了Daniel上面的提示,我能够解决这个问题。
我使用“从本地计算机上传文件脚本”将我的requirements.txt文件上传到Google Colab平台。脚本在here中找到。这就是脚本,
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])))
执行时的输出清楚地表明,它将此文件另存为'requirements.txt‘。然而,我在Google Drive中找不到这个文件,这对我来说很好。然后,
!pip install -r requirements.txt
成功了!
发布于 2020-05-28 11:04:03
您在Google Drive中找不到上载的文件。因为它是在Python3Google后端计算引擎中上传的。当您终止会话时,所有文件和数据都将被删除。
发布于 2021-12-15 10:33:47
您可以使用IPython神奇函数%%writefile
编写一个文件,然后执行一个!pip install -r requirements.txt
即:
单元1
%%writefile requirements.txt
<contents of your requiements.txt>
单元2
!pip install -r requirements.txt
https://stackoverflow.com/questions/50379804
复制相似问题