FileNotFoundError on relative path
- FileNotFoundError
- path
- open
The asker attempted to open a file that they assumed to be placed relative to the script, module or some other obvious “current path”.
>>> file1 = open('some_file.yaml')
FileNotFoundError: [Errno 2] No such file or directory: 'some_file.yaml'
The file is indeed not found due to wrong assumptions on the current working directory (CWD). Either the current working directory must be set correctly, or the path must be computed without regard to the current working directory.