Python cannot find a directory
Question:
I wrote a code like this with jupyter notebook in a project;
import os
image_path = r'C:UsersaysDesktopIR 1.jpg'
image_files = os.listdir(image_path)
img = cv2.imread(os.path.join(image_path,image_files))
cv2.imshow('image',img)
it gives an error like;
[WinError 3] The system cannot find the path specified: ‘C:UsersaysDesktopIR 1.jpg’
i was trying to print an image and
i had a directory problem
Answers:
Your image_path
seems to be a file, not a directory. Drop the file name and you should be OK:
image_path = r'C:UsersaysDesktopIR'
The argument to os.listdir()
must be the directory, not the image file, so remove
I wrote a code like this with jupyter notebook in a project;
import os
image_path = r'C:UsersaysDesktopIR 1.jpg'
image_files = os.listdir(image_path)
img = cv2.imread(os.path.join(image_path,image_files))
cv2.imshow('image',img)
it gives an error like;
[WinError 3] The system cannot find the path specified: ‘C:UsersaysDesktopIR 1.jpg’
i was trying to print an image and
i had a directory problem
Your image_path
seems to be a file, not a directory. Drop the file name and you should be OK:
image_path = r'C:UsersaysDesktopIR'
The argument to os.listdir()
must be the directory, not the image file, so remove