Google Colaboratory:导入数据,超出堆栈大小?

新手上路,请多包涵

我正在尝试使用此代码从我的文件夹中导入数据

from google.colab import files

uploaded = files.upload()

for fn in uploaded.keys():
  print('User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn])))

但它给了我这个错误:

 Traceback (most recent call last) <ipython-input-7-3ff52e25531b> in <module>()
      1 from google.colab import files
      2
----> 3 uploaded = files.upload()
      4
      5 #for fn in uploaded.keys():

/usr/local/lib/python3.6/dist-packages/google/colab/files.py in upload()
     70     result = _output.eval_js(
     71         'google.colab._files._uploadFilesContinue("{output_id}")'.format(
---> 72             output_id=output_id))
     73     if result['action'] != 'append':
     74       # JS side uses a generator of promises to process all of the files- some

/usr/local/lib/python3.6/dist-packages/google/colab/output/_js.py in eval_js(script, ignore_result)
     37   if ignore_result:
     38     return
---> 39   return _message.read_reply_from_input(request_id)
     40
     41

/usr/local/lib/python3.6/dist-packages/google/colab/_message.py in read_reply_from_input(message_id, timeout_sec)
    104         reply.get('colab_msg_id') == message_id):
    105       if 'error' in reply:
--> 106         raise MessageError(reply['error'])
    107       return reply.get('data', None)
    108
MessageError: RangeError: Maximum call stack size exceeded.

我不明白。是数据相对较大(22578685 字节)的原因还是因为 javascript?

原文由 i2_ 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 697
2 个回答

我的建议是尝试使用文件浏览器上传文件。 (它使用一种效率更高的独特传输方式,尤其是对于大文件。)

在此处输入图像描述

这能解决问题吗?

原文由 Bob Smith 发布,翻译遵循 CC BY-SA 4.0 许可协议

在我的 mac 上使用 colab in safari 然后它给了我这个错误。 Trien 从上面提到的按钮上传但没有用。

只需在 Google Chrome 中运行 colab,它就可以顺利运行。

原文由 Gayal Kuruppu 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进