Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

I'm trying to do the simplest thing ever and I can't get it to work.

I'm in my working directory, let's call it 'WorkDir' and this is it: C:\WorkDir

I want to create:

newpath = 'C:\WorkDir\Video\Files'

if not os.path.exists(newpath):

    os.makedirs(newpath)

FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\WorkDir\\Video'

I don't understand this error. Of course it can't find the file, it doesn't exist. Obviously I'm doing something wrong, but can't figure it out.

I also tried to use the period '.' to denote working directory, but that doesn't work either.

1 Answer

0 votes
by (25.1k points)

Your code seems to be correct. Please check if you have some antivirus or malware protection program  preventing changes in the folder.

Browse Categories

...