Google Colab-ValueError: Mountpoint must be in a directory that exists
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.
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.
@clarky: the error you got was correct tried to tell you that your usage of drive.mount() is incorrect: the mountpoint argument to drive.mount() must be an empty directory that exists, or the name of a non-existent file/directory in a directory that does exist so that the mountpoint can be created as part of the mount operation. Your usage of a relative path in drive.mount('content/drive/')
(i.e. content/drive/
) implies that the mount should happen at '/content/content/drive'
because the interpreter's default path is /content
; note the doubled content
path component there, and likely you don't already have a directory named /content/content inside of which a mountpoint named drive
could be created. The fix to your notebook code is to instead use drive.mount('/content/drive')
- note the leading /
making the mountpount path absolute instead of relative.