【发布时间】:2021-06-04 20:20:57
【问题描述】:
我的 GitHub 存储库中有一个 zip 文件。我想将它加载到我的 Google Colab 文件中。我有它的网址,可以从那里下载它,例如https://raw.githubusercontent.com/rehmatsg/../master/...zip
我使用这种方法将文件下载到 Google Colab 中
from google.colab import files
url = 'https://raw.githubusercontent.com/user/.../master/...zip'
files.download(url)
但我得到了这个错误
FileNotFoundError Traceback (most recent call last)
<ipython-input-5-c974a89c0412> in <module>()
3 from google.colab import files
4
----> 5 files.download(url)
/usr/local/lib/python3.7/dist-packages/google/colab/files.py in download(filename)
141 raise OSError(msg)
142 else:
--> 143 raise FileNotFoundError(msg) # pylint: disable=undefined-variable
144
145 comm_manager = _IPython.get_ipython().kernel.comm_manager
FileNotFoundError: Cannot find file: https://raw.githubusercontent.com/user/.../master/...zip
Google Colab 中的文件是临时文件,因此我无法每次都上传。这就是我想在项目的 GitHub 存储库中托管文件的原因。 将文件下载到 Google Colab 的正确方法是什么?
【问题讨论】:
-
查看您的链接,您的第一个链接的用户名是
rehmatsg。第二个有user。所以我认为这里的问题是您提供了错误的 URL。 -
不,实际上我的网址是有效的。我的问题中的这个只是一个例子
标签: python github google-colaboratory