I installed Python on my computer.
When I type python in the command prompt I get the following message:
'python' is not recognized as an internal or external command,
operable program or batch file.
But when I type py it seems to be working and I get the following:
Python 3.7.0 (v3.7.0, Jun 27 2018, 04:59:51) [MSC v.1914 64
bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license"
for more information.
Why is this happening?
FYI: I checked the path variable in environmental variables and I don't see any path to python installation.
But then how is visual code able to find the path to python.exe and able to run python code?
I am confused.
py is itself located in C:\Windows (which is always part of the PATH), which is why you find it. When you installed Python, you didn't check the box to add it to your PATH, which is why it isn't there. In general, it's best to use the Windows Python Launcher, py.exe anyway, so this is no big deal. Just use py for launching consistently, and stuff will just work. Similarly, if py.exe was associated with the .py extension at installation time, a standard shebang line (details in PEP linked above) will let you run the script without even typing py.
I don't know precisely what VSCode uses to find Python (using py.exe directly, using a copy of Python that ships with the editor, performing registry lookup, a config file that just says where to find it, etc.), but that's not really relevant to running your scripts yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With