1

Error when i want to use a file from driv in colab

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

and them

INPUT_DIRECTORY='/content/drive/My Drive/deepcumbia/data/xml'

error:

Could not find directory /content/drive/My/

2 Answers2

4

Escape the space.

INPUT_DIRECTORY='/content/drive/My\ Drive/deepcumbia/data/xml'
Bob Smith
  • 26,929
  • 9
  • 72
  • 69
1

This is to add another way which worked for me, i.e. double check the actual directory path in colab.

When debugging this same issue, I noticed Google Colab takes the Google Drive default directory a bit different. E.g. in Google Colab, the directory looked like this, there is no space in the word "MyDrive":

enter image description here

But when I browsed to the Google Drive, noticed there is a space in "My Drive": enter image description here

So, for my case, I changed from:

sth= pd.read_csv('/content/drive/My Drive/Colab Notebooks/Datasets/xyz.csv', index_col='abc')

to

sth= pd.read_csv('/content/drive/MyDrive/Colab Notebooks/Datasets/xyz.csv', index_col='abc')

Then it worked.

John5012
  • 29
  • 9