【问题标题】:Google colab Could not find directory (My Drive)Google colab 找不到目录(我的云端硬盘)
【发布时间】:2019-09-17 18:28:29
【问题描述】:

当我想在 colab 中使用驱动器中的文件时出错

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/

【问题讨论】:

标签: python artificial-intelligence google-colaboratory drive


【解决方案1】:

逃离空间。

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

【讨论】:

    【解决方案2】:

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

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

    但是当我浏览到 Google Drive 时,发现“我的 Drive”中有一个空格:

    所以,就我而言,我从:

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

    然后它起作用了。

    【讨论】:

      【解决方案3】:

      我以前也遇到过类似的问题。当链接或路径中有空格时会出现此问题。

      因此,这是通用解决方案:在空格前添加 \。

      所以,如果是dir = 'My Drive',请将其更改为dir = 'My\ Drive'

      它总是有效的。

      此外,这里是您的问题的解决方案:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-03-23
        • 2019-06-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-12
        相关资源
        最近更新 更多