Access to local folder with Colab

34,194

One option to access local files is to use Colab with a local install of Jupyter. Instructions to do that are here:

http://research.google.com/colaboratory/local-runtimes.html

Another option is to install Google Drive on your local machine, put the files there, and then mount your Drive files on Colab using the following snippet:

from google.colab import drive
drive.mount('/content/gdrive')

After that, your Drive files will appear in the built-in file browser. For example, enter image description here

Share:
34,194
MysteryGuy
Author by

MysteryGuy

I know it is paradoxal to be called MysteryGuy and to have a picture so that you will perfectly be able to discover who I really am by browsing a few minutes... But I am paraxodal

Updated on November 01, 2021

Comments

  • MysteryGuy
    MysteryGuy over 2 years

    I want to make a deep learning system on Colab. My data are stored in a local folder on my laptop but I don't know how to acceed it.

    When I do this, it gives me an error :

    import os
    output = [dI for dI in os.listdir(main_folder) if os.path.isdir(os.path.join(main_folder,dI))]
    print (output)
    
    [Errno 2] No such file or directory:
    

    main_folder is a local path : C:/.../.../

  • matanster
    matanster over 5 years
    I guess with the google drive way, you'd load the files in the notebook's code a la stackoverflow.com/a/51940120/1509695
  • user96265
    user96265 over 4 years
    I tried what was in the manual, got the link, connected locally and did a os.listdir(...) and it worked the first time. Then it said, PermissionError: [Errno 1] Operation not permitted: '/Users/esfandiar/...' This is extremely frustrating.
  • Wolfram Arnold
    Wolfram Arnold over 3 years
    There is now also a way to mount Google Drive straight from the UI without issuing any commands.