Forums

FileNotFoundError: [Errno 2]

I am coming across this error. The flask.py runs other scripts fine and even outputs text from 'femalenames.txt' but when it comes to loading the actual website I get this error. Any clues?

relevant error log:

2021-01-13 22:11:00,170: Error running WSGI application 2021-01-13 22:11:00,171: FileNotFoundError: [Errno 2] No such file or directory: 'femalenames.txt'

These files are in the same directory as the py file running them.

Resolved it by changing fid = open('femalenames.txt') to fid = open('/home/user/mysite/femalenames.txt') in script.

Yes -- in such cases using absolute path instead of relative one solves the issue. Great you figured that out!