简体   繁体   English

如何在不使用 Google Drive 的情况下从 Github 将文件上传到 Colab?

[英]How to upload files to Colab from Github without using Google Drive?

I have started to use Colab.我已经开始使用 Colab。 Now I want to from the notebook automatically upload a couple of smaller files from my Github repository.现在我想从笔记本中自动从我的 Github 存储库上传几个较小的文件。 My idea is that I should try to upload these files directly to the workspace of the Colab virtual machine and use of Google Drive not necessary.我的想法是我应该尝试将这些文件直接上传到 Colab 虚拟机的工作区,并且不需要使用 Google Drive。 This strategy should also facilitate sharing the notebook with others.此策略还应有助于与他人共享笔记本。

My Colab notebook code is as follows:我的 Colab 笔记本代码如下:

%%bash
git clone https://github.com/my_repository/folder1

%load folder1/file1.py

run -i file1.py

%load folder1/file2.zip

The first two command works fine but the two last gives error messages.前两个命令工作正常,但最后两个命令给出错误消息。

The error message when I try run file1.py is:我尝试运行 file1.py 时的错误消息是:

ERROR: root:File 'file1.py' not found.

And the error message when I try to load file2.zip当我尝试加载 file2.zip 时出现错误消息

File "<string>", line unknown
SyntaxError: invalid or missing encoding declaration for 'folder1/file2.zip'

(The file2.zip contains both some text file and an executable file for linux environment) (file2.zip 包含一些文本文件和 linux 环境的可执行文件)

How to solve this?如何解决这个问题?

Note1.注1。 If I check the directory after the second command with !ls I see I have folder1 and when I do !ls folder1 then I see the content of that folder1.如果我使用 !ls 检查第二个命令之后的目录,我看到我有 folder1,当我执行 !ls folder1 时,我会看到该 folder1 的内容。 So looks ok so far.所以到目前为止看起来还不错。

Note2.笔记2。 If I mount my Google Drive and upload the folder here then I can get it all to work.如果我挂载我的 Google Drive 并在此处上传文件夹,那么我可以让它全部工作。 But I want to avoid using Google Drive since that complicates sharing of the notebook, in my eyes.但我想避免使用 Google Drive,因为在我看来,这会使笔记本的共享变得复杂。

Note3.注3。 What I can see the zip-file contains a binary that is described as ELF 64-bit LSB shared object, x86-64, version 1 (SYSV)我可以看到 zip 文件包含一个二进制文件,该二进制文件被描述为 ELF 64 位 LSB 共享对象 x86-64,版本 1 (SYSV)

I found a solution I think and the code should be:我找到了一个我认为的解决方案,代码应该是:

%%bash
git clone https://github.com/my_repository/folder1

%cd folder1

run -i file1.py

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Colab上传大文件到GitHub? - How to upload large files from Colab to GitHub? 如何将包含多个文件夹的文件夹从谷歌驱动器上传到谷歌 colab - How to upload folder with multiple folders from google drive to google colab 在 Python Colab Google 中,如何从 DRIVE 上传(读取)一些或多个文件 (gif) - In Python Colab Google, How to upload (read) some or several files (gif) from DRIVE 如何设置从 Google Colab 到 Google Drive 文件的路径? - How to set the path to Google Drive files from Google Colab? 如何使用 Google colab 将文件下载到 Google Drive? - How to download files to Google Drive using Google colab? 使用 Google Colab 删除 Google Drive 上的文件 - Remove files on Google Drive using Google Colab 使用谷歌驱动器中的文件而不是在 colab 中上传 - Using files from google drive rather than uploading in colab 有没有办法访问本地文件,而无需在Google Colab中使用upload()选项或将数据上传到驱动器然后访问它 - Is there a way to access local files without having to use upload() option in Google Colab or uploading the data to the drive and then accessing it 如何使用 Google Colab 从 Github 存储库运行 .py 文件? - How to use Google Colab to run .py files from Github repositories? 如何遍历 Google Drive 文件夹中的多个文本 (.txt) 文件以上传到 Google Colab? - How do I iterate through multiple text(.txt) files in a folder on Google Drive to upload on Google Colab?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM