+ 1
Pyhthon: can’t open file ‘hello.py’: [Errno 2] No such file or directory
It was running before. Now i open the same file it doesn’t open. However I didn’t change file location. Kindly guide me someone
5 ответов
0
You should be able to solve the problem then by writing the complete path instead of the 'take it from the current directory' simple solution.
On my smart phone, using QPython or Pydroid, 'this directory' NEVER worked. Well...
I hope you were able to load your file now.
+ 3
HonFu I believe QPython uses an app-local script directory. This ends up being the 'current working directory" for the script, so I think you either have to get QPython to run from/save elsewhere or "cd" inside Python to change the working dir (then "open in current dir" should work). (You can also Ctrl-C a paused QPython script and drop to a terminal shell / look around)
(both of you)
The "current working directory" applies regardless of OS:
os.getcwd() # current working directory
os.chdir() # fix it from perspective of running script
+ 1
Did you start the program differently, like once in console mode, once in IDLE?
+ 1
Kirk Schafer, thanks, I'll play around with it, that should make things easier!
0
i m compiling the code in PC.
command prompt (Cmd) python