0

Python 3.8 installed on Windows 10 in C:\Python directory. C:\Python and C:\Python\Scripts added to both system and user environmental variables (path). (See attached image.)enter image description here

But, Python won't run from a command line. When I type python, the Microsoft Store pops up asking to install Python 3.7.

I have to be in the C:\Python directory and I have to type python.exe for it to run.

Any idea what's going on?

1 Answer 1

0

Looks like your launched that command prompt before editing the PATH environment variable, as the Python install directory isn't in the path output. The new environment settings are only applied to fresh prompts, not existing ones.

But really, don't bother with that anyway. Just use the py.exe Windows launcher which is automatically placed in your Windows directory (e.g. C:\Windows) which is already in your PATH. To launch with the latest installed Python 3, just run:

py -3

for the latest Python 2:

py -2

If you had the installer associate the launcher with the .py extension, you can put shebang lines in your scripts and they'll "Just Work". For GUI apps, pyw.exe and the .pyw extension serve the same purpose.

4
  • Thanks for that. py worked great! And, it launched 3.8, as expected.
    – T2true
    Feb 26, 2020 at 2:15
  • ...You mentioned the launcher. I am having a problem with that as well. I don't recall specifically associating the launcher with .py files. And, #! doesn't work - "not recognized as an internal or external command, operable program or batch file." I have to be in the python directory and type py.exe script.py or python.exe script.py.
    – T2true
    Feb 26, 2020 at 2:20
  • Is there a way to go back and have the launcher associated?
    – T2true
    Feb 26, 2020 at 2:21
  • @T2true: py.exe should work from anywhere, not just the Python directory, even if it wasn't associated with .py files. The association just allows you to double-click them (or run them as executables from the command line) without needing to mention py/python at all. You can always just reinstall Python and make sure the right boxes are checked. Feb 26, 2020 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.