+ 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

27th Dec 2018, 3:39 PM
Zarak Shakeel
Zarak Shakeel - avatar
5 RĂ©ponses
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.
27th Dec 2018, 3:59 PM
HonFu
HonFu - avatar
+ 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
27th Dec 2018, 5:36 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Did you start the program differently, like once in console mode, once in IDLE?
27th Dec 2018, 3:50 PM
HonFu
HonFu - avatar
+ 1
Kirk Schafer, thanks, I'll play around with it, that should make things easier!
27th Dec 2018, 5:49 PM
HonFu
HonFu - avatar
0
i m compiling the code in PC. command prompt (Cmd) python
27th Dec 2018, 4:08 PM
Zarak Shakeel
Zarak Shakeel - avatar