Colabtools: Unable to upload local files: google.colab.__files is undefined

Created on 8 Feb 2018  路  11Comments  路  Source: googlecolab/colabtools

Using the file upload code snippet on both python3 and python2 I get the error message:

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

Most helpful comment

There is a new file upload UI in the notebook sidebar, alongside the table of contents.

All 11 comments

I can't seem to reproduce this -- does this always happen, or only sometimes?

If you open the chrome JS console (ctrl-shift-j or cmd-shift-j on a mac), do you have any errors there?

Which browser is this occurring in? If Chrome, are you seeing a warning when initially opening the document?

I am using Firefox 58.0.1 (64 bit) on Ubuntu 17.10 with lxqt env

I'm working on a fix for this, in the meantime I would recommend using Chrome. This is specifically running into https://bugzilla.mozilla.org/show_bug.cgi?id=1279406.

I'm also experiencing the same issue on Safari 11.0.3. I guess I'll stick to Chrome.

Safari's Service Worker implementation is available in the preview version, though we haven't had a chance to test them yet. See https://webkit.org/status/#specification-service-workers.

I am adding some context for other people because I found a link to this issue from an stackoverflow answer.

Shortly: Chrome works if third-party cookies are enabled in settings. No easy or complicated solution exists currently for Firefox (that say posts above)

I wrote some summary about files.upload(), especially for people that search a solution by error messages.

It would be nice to customize the message

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

and replace the words "Please rerun this cell to enable." by "This browser is probably not supported for upload." if detected by some simple whitelist or blacklist.

This will help very much temporarily. (question "I rerun the cell but it doesn't work...")

It also helps to get more complete questions or issue reports because all four questions at stackoverflow that I found (and fixed little) were without information about the browser and sometimes neither considered it in answers. (like "I have no problem.")

It is also happening in google chrome.

There is a new file upload UI in the notebook sidebar, alongside the table of contents.

You can also just reimport all your packages

Was this page helpful?
0 / 5 - 0 ratings