Google colab找不到目录(“我的云端硬盘”)

时间:2019-09-17 18:28:29

标签: python artificial-intelligence google-colaboratory drive

我要在colab中使用driv中的文件时出错

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

还有他们

INPUT_DIRECTORY='/content/drive/My Drive/deepcumbia/data/xml'

错误:

Could not find directory /content/drive/My/

2 个答案:

答案 0 :(得分:1)

逃脱空间。

INPUT_DIRECTORY='/content/drive/My\ Drive/deepcumbia/data/xml'

答案 1 :(得分:1)

这是添加另一种对我有用的方法,即仔细检查 colab 中的实际目录路径。

在调试同一问题时,我注意到 Google Colab 采用的 Google Drive 默认目录略有不同。 例如。在 Google Colab 中,目录如下所示,“MyDrive”一词中没有空格:

enter image description here

但是当我浏览到 Google Drive 时,注意到“我的驱动器”中有一个空格: enter image description here

所以,就我而言,我从:

sth= pd.read_csv('/content/drive/My Drive/Colab Notebooks/Datasets/xyz.csv', index_col='abc')

sth= pd.read_csv('/content/drive/MyDrive/Colab Notebooks/Datasets/xyz.csv', index_col='abc')

然后就成功了。