从colab下载大文件失败

时间:2018-08-07 20:39:59

标签: python-3.x tar google-colaboratory

我正尝试使用以下代码下载一个已压缩为.tar文件的目录。 .tar文件似乎已下载,但比colab上显示的文件小得多。我也收到下面的错误信息。有人可以让我知道下面的错误消息是什么意思,还有没有更好的方法来下载文件?

代码:

# compressing folder

!tar -cvf DVBPR.tar DVBPR/


# download files to local computer

from google.colab import files

files.download('DVBPR.tar')

错误:

Exception happened during processing of request from ('::ffff:127.0.0.1', 59040, 0, 0)
Traceback (most recent call last):
  File "/usr/lib/python3.6/socketserver.py", line 317, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 348, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/socketserver.py", line 696, in __init__
    self.handle()
  File "/usr/lib/python3.6/http/server.py", line 418, in handle
    self.handle_one_request()
  File "/usr/lib/python3.6/http/server.py", line 406, in handle_one_request
    method()
  File "/usr/lib/python3.6/http/server.py", line 639, in do_GET
    self.copyfile(f, self.wfile)
  File "/usr/lib/python3.6/http/server.py", line 800, in copyfile
    shutil.copyfileobj(source, outputfile)
  File "/usr/lib/python3.6/shutil.py", line 82, in copyfileobj
    fdst.write(buf)
  File "/usr/lib/python3.6/socketserver.py", line 775, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer

2 个答案:

答案 0 :(得分:0)

了解此错误here。我认为这通常是由于无法使用良好的互联网连接而发生的。连接良好后,请尝试一下。

您也可以尝试按照here的说明安装驱动器,然后将其复制到驱动器上。然后使用下载管理器下载文件。

答案 1 :(得分:0)

这篇文章似乎解决了我的问题。与其在本地下载,不如使用帖子中的代码将其保存到我的google驱动器中:

How to download large files (like weights of a model) from Colaboratory?