Reputation: 13
I've been studying Python for a month now and normally I run all my programs in Sublime Text 3.
Today I learn to run Python programs in the terminal window as introduced in this section of the Automate the Boring Stuff with Python book following this video. Basically, I followed the instruction in the video and created the hello.py file as below:
#! python3
print('Hello, World!')
Then I opened the Command Prompt to run the file with the command: py.exe c:\users\danh\mypythonscripts\hello.py
,
an error pops-up and states that "This app can't run on your PC" and a line says that Access is denied. I spent the whole day trying to fix this problem but still I couldn't get it running.
One thing is when I change the directory of the Command Prompt to run the file to C:Windows\system32 (or run the Command Prompt as Administrator) and then run the command py.exe c:\users\danh\mypythonscripts\hello.py
, it runs the file without any problem as in this image.
Does anyone know how to fix this problem? Any help is appreciated. Thanks!
Upvotes: 0
Views: 3458
Reputation:
python.exe
inside my env\Scripts\
became 0kb for some reason. So I created another virtual-env and copied python.exe
from there to this folder. then it started working.
Upvotes: 0
Reputation: 13
I solved the problem.
When I looked into my user directory at C:\Users\<Username>
, it appears that there is a py.exe
file that has 0 bytes.
I was told in this thread that the py.exe
file shouldn't be in my user directory so I removed that file and it fixed the problem.
I still don't know how the py.exe
file got into my user directory and why it has 0 bytes so I'm not sure this solution could help others. For now, I will accept my own answer because it solves the problem in my case.
Upvotes: 1
Reputation: 6426
It looks like you're trying to use Microsoft's new Windows 10 Metro-based auto-installing version of Python. It's included by default but, as you've found, it doesn't work very well.
Try installing the version from the Python website.
If you've got a 32-bit copy of Windows, make sure to install the 32-bit version; Windows isn't very good at running 64-bit programs from a 32-bit kernel. You can check by looking in your C: drive; if you haven't got a Program Files (x86) folder, install the 32-bit version.
Upvotes: 0