Forum Archive

FileNotFoundError

Alex812

I got an error when my program tried to open file f=open('dia.dat','r') if it starts from home screen.No errors if it starts from IDE. Error message:
FileNotFoundError
[Errno 2] No such file or directory: 'via.dat'
How to fix the problem?

iPhone 5SE iOS 10.3.3

JonB

When you run a script from the editor, the path is changed to the folder containing the script.
From the console, you might need a os.chdir.

When you get this error, try in the console:

import os
print(os.path.abspath('.'))
Alex812

Thank you! Now I can read file and also open .pyui file when program starts from home screen.