Jonah Geladze
Jonah Geladze

Reputation: 373

ValueError: Mountpoint must not contain a space. (Colab)

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

Answers (6)

marcinj
marcinj

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

Ritesh
Ritesh

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

Mahmoud
Mahmoud

Reputation: 11431

There is a dedicated button in the sidebar that pastes the necessary cell to mount the drive:

enter image description here

Upvotes: 2

suria sarath
suria sarath

Reputation: 481

Try this way it's working.

cd 'My Drive'/

Upvotes: -2

Suleman
Suleman

Reputation: 397

  1. Mount at /content/drive

    from google.colab import drive
    drive.mount('/content/drive')
    
  2. Change directory using cd command

    cd 'drive/My Drive'
    

enter image description here

Upvotes: 15

Bob Smith
Bob Smith

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

Related Questions