Google Colab-ValueError:挂载点必须位于存在的目录中 [英] Google Colab-ValueError: Mountpoint must be in a directory that exists

查看:311
本文介绍了Google Colab-ValueError:挂载点必须位于存在的目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在google Colab上安装google驱动器,并且我正在使用此命令来安装驱动器

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/')

但我收到此错误

ValueError                               Traceback (most recent call last)
<ipython-input-45-9667a744255b> in <module>()
       1 from google.colab import drive
 ----> 2 drive.mount('content/drive/')

 /usr/local/lib/python3.6/dist-packages/google/colab/drive.py in
 mount(mountpoint, force_remount)
      99       raise ValueError('Mountpoint must either be a directory or not exist')
     100     if '/' in mountpoint and not _os.path.exists(_os.path.dirname(mountpoint)):
 --> 101       raise ValueError('Mountpoint must be in a directory that exists')
     102   except:
     103     d.terminate(force=True)

 ValueError: Mountpoint must be in a directory that exists

推荐答案

@clarky:您得到的错误是正确的,试图告诉您您对drive.mount()的使用是不正确的:drive.mount()的mountpoint参数)必须是存在的空目录,或者是存在的目录中不存在的文件/目录的名称,以便可以将安装点创建为安装操作的一部分.您在drive.mount('content/drive/')(即content/drive/)中使用相对路径意味着该挂载应该发生在'/content/content/drive',因为解释器的默认路径是/content;请注意,其中的content路径组件已加倍,并且可能还没有一个名为/content/content的目录,可以在其中创建名为drive的挂载点.解决笔记本代码的方法是改用drive.mount('/content/drive')-注意前导/使mountpount路径变为绝对路径,而不是相对路径.

@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.

这篇关于Google Colab-ValueError:挂载点必须位于存在的目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆