首页 > 解决方案 > FileNotFoundError:[Errno 2] 没有这样的文件或目录:'/content/drive/My'

问题描述

你们有没有遇到过这个错误?

我正在为我的小项目使用 GoogleColab。对于我的项目,我重新安装了 keras 2.1.5 & tensorflow 1.4 甚至没有忘记重启运行时。

这是错误代码:

/usr/local/lib/python3.6/dist-packages/PIL/Image.py in open(fp, mode)
   [2808]     if filename: 
-> [2809]         fp = builtins.open(filename, "rb")
   [2810]         exclusive_fp = True
   [2811]

FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/My'

我有一个名为“/content/drive/My Drive/Folder/Folder”的文件夹(是的,“My”和“Drive”之间有一个“空格”)。我认为这是一种错误或某事,不是吗?我试图将该文件夹名称修复为“My_Drive”或“MyDrive”,但 Google 不接受修复该名称。

或者有什么解决办法吗?请帮我。

+)

这里是整个代码:(基本上来自yolov3-to-keras https://github.com/qqwweee/keras-yolo3.git)

!pip install q keras==2.2.4
%tensorflow_version 1.x

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

cd 'drive/My Drive'


...same as train.py...

def _main():
        annotation_path = 'train_all.txt'
        log_dir = 'logs/000/'
        classes_path = 'classes.txt'
        anchors_path = 'model_data/tiny_yolo_anchors.txt'
        class_names = get_classes(classes_path)
        num_classes = len(class_names)
        anchors = get_anchors(anchors_path)'

...same as 'train.py'...

_main()

而且我还尝试复制路径并使用它,但没有奏效。在它们之间添加'\',没有用。

快把我逼疯了哈!

标签: google-colaboratory

解决方案


你可以试试 if'My\ Drive'工作,而不是'My Drive'


推荐阅读