python - 在 Google Colab 中从 GitHub 加载 .zip 文件
问题描述
我的 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 的正确方法是什么?
解决方案
使用“wget”bash 命令。只需打开 Github 项目并转到下载为 zip 选项(在右上角)。然后,复制 url 并使用“wget”命令。
!wget https://github.com/nytimes/covid-19-data/archive/refs/heads/master.zip
!unzip /content/master.zip
祝你好运。
推荐阅读
- angular - Angular如何在组件中测试来自EventEmitter的订阅
- vuejs3 - Swiper Vue.js 没那么好用?
- python - 为买卖双方应用条件以从风筝中获取数据
- reactjs - 部署 heroku 错误:未能将一些引用推送到
- apache-kafka - 将 Lagom 连接到外部 Kafka 服务器(在 Confluent Cloud 上)
- python - 到特定日期的行中的数据框价格平均值
- html - 嵌套行填充溢出到引导程序 5 中的父行
- javascript - 我不能点击一个带有硒的元素,我怎么能点击呢?
- python - 将字典中单词的值分配给数据框内容
- r - 在多列上聚合 sf 对象