Google colab下载-ConnectionResetError:[Errno 104]对等重置连接

时间:2020-05-31 13:50:39

标签: python file download connection google-colaboratory

我正在使用google colab,我想自动下载文件(可能很大:〜100Mo)。目前,我正在使用:

from google.colab import files

files.download('results.zip')

但这并不总是一致的,并且在大多数情况下,我会收到错误:ConnectionResetError: [Errno 104] Connection reset by peer

Exception happened during processing of request from ('::ffff:127.0.0.1', 55642, 0, 0)
Traceback (most recent call last):
  File "/usr/lib/python3.6/socketserver.py", line 320, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 351, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 364, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/socketserver.py", line 724, 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 803, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer

我该如何解决?还是有任何解决方法可以自动从colab下载文件?

谢谢!

1 个答案:

答案 0 :(得分:0)

为了提高可靠性,建议您在左侧窗格中使用文件浏览器,而不要使用files.download,尤其是在文件较大的情况下。

enter image description here

另一种选择是挂载Google云端硬盘,然后在其中复制results.zip文件。 Google云端硬盘同步也可能比直接下载更快。

相关问题