python - Google Colab-ValueError:挂载点必须位于存在的目录中
问题描述
我想在谷歌 Colab 上挂载谷歌驱动器,我正在使用这个命令来挂载驱动器
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/')
您在(ie )中使用相对路径content/drive/
意味着安装应该发生在,'/content/content/drive'
因为解释器的默认路径是/content
; 请注意content
那里的双路径组件,并且可能您还没有一个名为 /content/content 的目录,drive
可以在其中创建一个名为的挂载点。对笔记本代码的修复是改为使用drive.mount('/content/drive')
- 注意前导/
使安装点路径是绝对的而不是相对的。
推荐阅读
- macos - jenkins 权限在运行 cd 命令时被拒绝
- mysql - 使用 if else 条件触发
- angular - Angular 6材料表示意图:如何从远程加载数据?
- python - 如何在绘图中添加颜色,python 模式 [语法错误]
- javascript - 如何使用 GET 请求从 PHP 中的输入表单发送数组?
- c# - 如何在 DataGridView 单元格中显示 Linq 查询
- date - 在 SharePoint 列中将日期转换为 Julian 以显示 YYYYMonth(拼写出来)DD - 2018June15
- android - 无法为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象获取未知属性“ANDROID_SDK_VERSION”
- kubernetes - Kubernetes 部署超级账本结构
- go - Golang 命令行字符串标志