FileNotFoundError
noun
say it: “FYLE not FOWND AIR-er” /ˈfaɪl ˈnɑt ˈfaʊnd ˈɛrər/
The error Python raises when a program tries to open a file that isn't at the path it was given.
What is a FileNotFoundError?
A FileNotFoundError is the error Python raises when it's asked to open a file that isn't where the program looks: often a misspelled name, or a terminal open in another folder.
with open("scores.txt") as file:
print(file.read())
# FileNotFoundError: [Errno 2] No such file or directory: 'scores.txt'
In a sentence
- “The program catches FileNotFoundError and starts a new, empty log instead.”
- “The run log raised a FileNotFoundError because the terminal was open in another folder.”
Level: Apprentice · More Python terms at this level
Updated