Search code examples
pythongoogle-colaboratorydrive

google drive address in google colaboratory


I am new to google colaboratory.

In My Drive there are my required files. the address of train.py file is:

gdrive/My Drive/Colab Notebooks/Project_Folder/DELTA-master/DELTA-master/train.py.

I use this address in a cell as follow to run train.py:

! python gdrive/My Drive/Colab Notebooks/Project_Folder/DELTA-master/DELTA-master/train.py

but I get this error:

FileNotFoundError: [Errno 2] No such file or directory: 'gdrive/My Drive/Colab Notebooks/Project_Folder/DELTA-master/DELTA-master/train.py'

Can anyone help me?!


Solution

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

    Use this to generate an authentication code and make the drive accessible.

    Then in colab, under files in the left side tab, see if you can locate the file. Then right click on the file and select copy path.

    Or you can use

    /content/drive/My\ Drive/ <path to your file in gdrive>
    

    Don't forget to put "\" whereever the foldername has space in it