Reputation: 373
Here is my code in google colab:
from google.colab import drive
drive.mount('content/drive/My Drive/ML')
I have a path which contains space symbol and I get this error:
/usr/local/lib/python3.6/dist-packages/google/colab/drive.py in mount(mountpoint, force_remount, timeout_ms) 89 90 if ' ' in mountpoint: ---> 91 raise ValueError('Mountpoint must not contain a space.') 92 93 mountpoint = _os.path.expanduser(mountpoint)
ValueError: Mountpoint must not contain a space.
I have tried drive.mount('content/drive/My\ Drive/ML') and this doesn't work
Upvotes: 23
Views: 33725
Reputation: 49976
What worked for me was:
import os
from google.colab import drive
path = '/content/drive/'
drive.mount(path)
path = '/content/drive/MyDrive/Projects/Generative_Deep_Learning_2nd_Edition'
os.chdir(path)
I needed make this import work:
from notebooks.utils import display
notebooks
is a folder under /content/drive/MyDrive/Projects/Generative_Deep_Learning_2nd_Edition
Upvotes: 0
Reputation: 23
Use the following code:
from google.colab import drive
drive.mount("/content/gdrive")
Please note about gdrive.
It will then ask for authentication code and once you give the same, the drive will be mounted successfully.
Mounted at /content/gdrive
Once the drive is mounted, you can navigate just like on your local machine.
Upvotes: 0
Reputation: 11431
There is a dedicated button in the sidebar that pastes the necessary cell to mount the drive:
Upvotes: 2
Reputation: 397
Mount at /content/drive
from google.colab import drive
drive.mount('/content/drive')
Change directory using cd command
cd 'drive/My Drive'
Upvotes: 15
Reputation: 38579
Run instead:
from google.colab import drive
drive.mount('/content/drive')
The leading /
is important. Once mounted at /content/drive
, you'll see My Drive/ML
in that directory. /content/drive
is the directory path on your local machine. My Drive/ML
is the path within your Drive. (My Drive
distinguishes your Drive from Team drives.)
Upvotes: 7