Filenotfounderror winerror 3 The system cannot find the path specified mkdir

os.mkdir(path) FileNotFoundError: [WinError 3] The system cannot find the path specified

Filenotfounderror winerror 3 The system cannot find the path specified mkdir

猫耳君

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
于 2021-03-02 09:57:11 发布
Filenotfounderror winerror 3 The system cannot find the path specified mkdir
782
Filenotfounderror winerror 3 The system cannot find the path specified mkdir
收藏

os.mkdir(path)FileNotFoundError: [WinError 3] The system cannot find the path specified

在使用django的过程中,发现当创建多级文件夹的时候,使用mkdir会出错,此时将mkdir改为makedirs即可。

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    0

    点赞

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    0

    收藏

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir

    打赏

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    0

    评论

08-01

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
130

11-23

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
862

04-29

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
437

02-20

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
836

11-24

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
1401

02-17

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
1481

12-15

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
4570

11-06

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
885

04-02

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
1万+

12-27

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
1万+

03-13

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
3643

02-01

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
950

04-21

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
945

04-29

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
448

12-09

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
219

06-13

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
255

10-16

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
1074

08-30

Filenotfounderror winerror 3 The system cannot find the path specified mkdir
9628

“相关推荐”对你有帮助么?

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    Filenotfounderror winerror 3 The system cannot find the path specified mkdir

    非常没帮助

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    Filenotfounderror winerror 3 The system cannot find the path specified mkdir

    没帮助

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    Filenotfounderror winerror 3 The system cannot find the path specified mkdir

    一般

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    Filenotfounderror winerror 3 The system cannot find the path specified mkdir

    有帮助

  • Filenotfounderror winerror 3 The system cannot find the path specified mkdir
    Filenotfounderror winerror 3 The system cannot find the path specified mkdir

    非常有帮助

©️2022 CSDN 皮肤主题:1024 设计师:我叫白小胖 返回首页

The system cannot find the path specified: ‘ ‘

I am trying to split my image data set into train test and val. It has already created the train, test and val folders, but its empty as I keep encountering an error. This is the code I am trying to run on jupyter notebook, I have imported the required libraries like os, numoy, shutil, random:

# # Creating Train / Val / Test folders root_dir = 'Desktop/sem_8_project/brain/brain_tumor_dataset/' # data root path classes_dir = ['no', 'yes'] #total labels val_ratio = 0.15 test_ratio = 0.05 for cls in classes_dir: os.makedirs(root_dir +'train/' + cls) os.makedirs(root_dir +'val/' + cls) os.makedirs(root_dir +'test/' + cls) for cls in classes_dir: src = root_dir + cls # Folder to copy images from allFileNames = os.listdir(src) np.random.shuffle(allFileNames) train_FileNames, val_FileNames, test_FileNames = np.split(np.array(allFileNames),

and this is the error it shows:

--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-34-e2cee9006649> in <module> 3 src = root_dir + cls # Folder to copy images from 4 ----> 5 allFileNames = os.listdir(src) 6 np.random.shuffle(allFileNames) 7 train_FileNames, val_FileNames, test_FileNames = np.split(np.array(allFileNames), FileNotFoundError: [WinError 3] The system cannot find the path specified: 'Desktop/sem_8_project/brain/brain_tumor_dataset/no'

Answer

In the last 4 lines of code instead of using: allFileNames = os.listdir(src) I used:

allFileNames = [] for filename in os.listdir(src): img = cv2.imread(os.path.join(src,filename)) if img is not None: allFileNames.append(img)

This worked for me and the directory error got fixed.