JupyterNotebook: FileNotFoundError: [WinError 3] The system cannot find the path specified

Viewed 2827

I've created folder structures with code on my desktop, and filled them with images using the cap=cv2.VideoCapture() with no problem.

To create folder structures and make directories, I wrote this code and it works fine:

#SETUP PATHS
POS_PATH = os.path.join('data', 'positive')
NEG_PATH = os.path.join('data', 'negative')
ANC_PATH = os.path.join('data','anchor')


#MAKE DIRECTORIES
os.makedirs(POS_PATH)
os.makedirs(NEG_PATH)
os.makedirs(ANC_PATH)

folderstructures_on_desktop

But, when I want to list images in a file, I get this error:

os.listdir('positive')

ERROR: FileNotFoundError: [WinError 3] The system cannot find the path specified: 'positive'

Can you help me?

1 Answers

tl;rd

os.listdir('data/positive')

Detailed answer:

If you will use the following command:

os.listdir('positive')

you will get the FileNotFoundError:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-6-f6aeca1b018e> in <module>
----> 1 os.listdir('positive')

FileNotFoundError: [Errno 2] No such file or directory: 'positive'

The reason for that is that the actual location of this directory is:

'data/positive'

See the proper command below:

os.listdir('data/positive')

I prepared an example Jupyter Notebook presenting this case. I hope that you will find this example useful: https://gist.github.com/mikbuch/73401b8fa7289113417b35f1144cb179

Related