简体   繁体   English

无法在google colab中上传本地文件

[英]Not able to upload local files in google colab

I am trying to upload a word2vec file in Google Colaboratory from local system and use it further in the in code.我正在尝试从本地系统在 Google Colaboratory 中上传一个 word2vec 文件,并在代码中进一步使用它。

This is the code that I used.这是我使用的代码。

from google.colab import files
uploaded = files.upload()

Everytime I execute it, it is showing the following error.每次我执行它时,它都会显示以下错误。

Upload widget is only available when the cell has been executed in the current browser session. Please rerun this cell to enable上传小部件仅在当前浏览器 session 中执行单元格时可用。请重新运行此单元格以启用

 MessageError  Traceback (most recent call last)
<ipython-input-1-292f82be1b7a> 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() 

     59   result = output.eval_js(
     60       'google.colab._files._uploadFiles("{input_id}", "{output_id}")'.format(
---> 61           input_id=input_id, output_id=output_id))
     62   files = collections.defaultdict(six.binary_type)
     63 

/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)

     84         reply.get('colab_msg_id') == message_id):
     85       if 'error' in reply:
---> 86         raise MessageError(reply['error'])
     87       return reply.get('data', None)
     88 

MessageError: TypeError: google.colab._files is undefined

Why is this happening?为什么会这样? What should I do?我应该怎么办?

This issue is currently being investigated for Firefox at: https://github.com/googlecolab/colabtools/issues/51 .目前正在针对 Firefox 调查此问题: https : //github.com/googlecolab/colabtools/issues/51

As a temporary workaround is there recommended to upload files by Chrome.作为临时解决方法,建议使用 Chrome 上传文件。

Switching off Enhanced Protection for the site in Firefox, which is accessible via the little "security shield" to the left of the URL, did the trick perfectly for me...关闭 Firefox 中站点的增强保护(可通过 URL 左侧的小“安全盾牌”访问)对我来说完美无缺...

Well for me, I first tried to factory reset the runtime but it didn't work对我来说,我首先尝试出厂重置运行时,但它没有用

Then i just restarted the runtime and refreshed the page, it then worked for me.然后我只是重新启动运行时并刷新页面,然后它对我有用。

如果您使用的是勇敢的浏览器,请设置勇敢的盾牌中允许的所有 cookie。

For me, this happened when my computer was simply overloaded.对我来说,这发生在我的电脑超载时。 It was unable to manage colab and my other tabs being open.它无法管理 colab 并且我的其他选项卡处于打开状态。 Closing colab and the other tabs in the taskmanager before trying again solved the problem for me.在再次尝试之前关闭 colab 和任务管理器中的其他选项卡解决了我的问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM