Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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

 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?

like image 414
MEGHA MISHRA Avatar asked Feb 13 '18 06:02

MEGHA MISHRA


People also ask

How do I upload local Files to Colab?

Access local files through the file-explorer You can either use the upload option at the top of the file-explorer pane to upload any file(s) from your local file system to Colab in the present working directory. 2. Select the “upload” option.

How do I upload a folder from Google Drive to Google Colab?

On Google Drive, create a new folder and call it Kaggle. Open this folder by double-clicking on it and upload kaggle. json file. Next, open a Colab notebook and run the code below to mount the Drive onto Colab's file system.


2 Answers

This issue is currently being investigated for Firefox at: https://github.com/googlecolab/colabtools/issues/51.

As a temporary workaround is there recommended to upload files by Chrome.

like image 53
blois Avatar answered Sep 18 '22 17:09

blois


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.

like image 38
Arnav Das Avatar answered Sep 21 '22 17:09

Arnav Das