Show os.mkdir(path) FileNotFoundError: [WinError 3] The system cannot find the path specified猫耳君 于 2021-03-02 09:57:11 发布 782 收藏os.mkdir(path)FileNotFoundError: [WinError 3] The system cannot find the path specified在使用django的过程中,发现当创建多级文件夹的时候,使用mkdir会出错,此时将mkdir改为makedirs即可。
08-01 130 11-23 862 04-29 437 02-20 836 11-24 1401 02-17 1481 12-15 4570 11-06 885 04-02 1万+ 12-27 1万+ 03-13 3643 02-01 950 04-21 945 04-29 448 12-09 219 06-13 255 10-16 1074 08-30 9628 “相关推荐”对你有帮助么?
©️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' AdvertisementAnswerIn 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. |