Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k points)

For some reason my code is having trouble opening a simple file:

This is the code:

file1 = open('recentlyUpdated.yaml')

And the error is:

IOError: [Errno 2] No such file or directory: 'recentlyUpdated.yaml'

  • Naturally, I checked that this is the correct name of the file.

  • I have tried moving around the file, giving open() the full path to the file and none of it seems to work.

1 Answer

0 votes
by (106k points)
edited by

To get rid of this error you can try using os.listdir() function to check that at least python sees the file.

file1 = open(r'Drive:\Dir\recentlyUpdated.yaml')

To Learn what is python and python applications then visit this Data Science with Python Course.

Interested to learn more about Python? Come & join our Python course

Browse Categories