pythongoogle-colaboratorymount

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


Solution

  • 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.)