Google Colab-ValueError: Mountpoint must be in a directory that exists

前端 未结 10 896
心在旅途
心在旅途 2021-01-03 01:02

I want to mount google drive on google Colab and I am using this command to mount the drive

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


        
相关标签:
10条回答
  • 2021-01-03 01:13

    Replace drive.mount('/content/drive/') by drive.mount('/content/drive')

    0 讨论(0)
  • 2021-01-03 01:22

    I ran into this error this morning as well. I'm not sure what this commit what meant to fix but it certainly caused the error. A workaround is to copy the code for drive.py into colab, comment out lines 100 and 101 like this:

    # drive.py
    
    ...
    
      try:
        if _os.path.islink(mountpoint):
          raise ValueError('Mountpoint must not be a symlink')
        if _os.path.isdir(mountpoint) and _os.listdir(mountpoint):
          raise ValueError('Mountpoint must not already contain files')
        if not _os.path.isdir(mountpoint) and _os.path.exists(mountpoint):
          raise ValueError('Mountpoint must either be a directory or not exist')
        #  if '/' in mountpoint and not _os.path.exists(_os.path.dirname(mountpoint)):
        #    raise ValueError('Mountpoint must be in a directory that exists')
      except:
        d.terminate(force=True)
        raise
    
    ...
    

    then replace

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

    with

    mount('/content/drive/')
    

    using the mount function you copied from drive.py

    Hopefully the issue gets fixed quickly enough so we can do away with this workaround.

    0 讨论(0)
  • 2021-01-03 01:24

    just remove the '/' following the drive and it works perfectly..

    That is from drive.mount('/content/drive/') to drive.mount('/content/drive')

    0 讨论(0)
  • 2021-01-03 01:24

    Just go to "manage section" , then terminate your current section, and try to mount again with:

    from google.colab import drive
    drive.mount('/content/drive', force_remount=True) 
    

    It worked here.

    0 讨论(0)
  • 2021-01-03 01:26

    Run command to unmount drive first.

    !fusermount -u drive
    

    Then try run again,

    from google.colab import drive
    drive.mount('/content/drive')
    
    0 讨论(0)
  • 2021-01-03 01:27

    I received the error as well change to drive.mount('/content/drive')

    0 讨论(0)
提交回复
热议问题