Google colaboratory 从Google Colaboratory中的requirements.txt安装依赖项

Google colaboratory 从Google Colaboratory中的requirements.txt安装依赖项,google-colaboratory,Google Colaboratory,如何使用GoogleColab中的需求文件安装python依赖项 就像上面Daniel的提示相当于pip install-r requirements.txt一样,我能够解决这个问题 使用“从本地计算机脚本上载文件”,我将requirements.txt文件上载到Google Colab平台。找到脚本。这是剧本, from google.colab import files uploaded = files.upload() for fn in uploaded.keys(): prin

如何使用GoogleColab中的需求文件安装python依赖项


就像上面Daniel的提示相当于pip install-r requirements.txt一样,我能够解决这个问题

使用“从本地计算机脚本上载文件”,我将requirements.txt文件上载到Google Colab平台。找到脚本。这是剧本,

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”。然而,我在谷歌硬盘中找不到这个文件,这对我来说很好。那么

!pip install -r requirements.txt

成功了

在Google Drive中找不到上载的文件。因为它是在Python 3 Google后端计算引擎中上传的。当您终止会话时,所有文件和数据都将被删除。

在笔记本单元中尝试(使用前导!)时会出现什么错误?我不确定为需求文件提供什么路径如果您想上载本地文件,您应该签出。如果文件托管在web上,您能将URL传递给pip吗?是的,我们需要在每次重置容器/会话(而不是内核)时上载和安装需求