gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 21:02:16 26 4
gpt4 key购买 nike

我正在尝试从本地系统在 Google Colaboratory 中上传一个 word2vec 文件,并在代码中进一步使用它。

这是我使用的代码。

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

每次我执行它时,它都显示以下错误。

Upload widget is only available when the cell has been executed in the current browser session. Please rerun this cell to enable

 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

为什么会这样?我该怎么办?

最佳答案

目前正在为 Firefox 调查此问题:https://github.com/googlecolab/colabtools/issues/51 .

作为临时解决方法,建议通过 Chrome 上传文件。

关于python - 无法在google colab中上传本地文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48760475/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com