0

I'm on Windows 10 and have Python 3.9.0 installed. The evinronment variables I have for Python are C:\Users\Zimplfy\AppData\Local\Programs\Python\Python39\ and C:\Users\Zimplfy\AppData\Local\Programs\Python\Python39\scripts\ in PATH. For some reason whenever I type py inside Command Prompt I get:

'py' is not recognized as an internal or external command, operable program or batch file.

But when I type in python I get:

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

Anyone have an answer to why this could be?

Thanks in advance.

2
  • 1
    Please provide your environment PATH variable that contains the directory for Python. Please edit your question instead of submitting a comment
    – Ramhound
    Nov 11, 2020 at 21:15
  • py is a separate program and must be selected during the Python installation process (assuming you are using vanilla Python from Python.org). If you are using another distribution of Python (e.g. Anaconda), this program may or may not be included. Nov 11, 2020 at 21:33

3 Answers 3

2

Run in the command line:

doskey py = python

This creates an alias for the python command and then you can use py to start the python interpreter.

If you get an error regarding doskey not being recognized as an internal or external command, add C:\Windows\System32; to the PATH and run the command again. You can follow the more detailed instructions here to modify the PATH.

1
  • this is working. thanx a lot for sharing this accurate answer. this answer must be checked as problem answer. Dec 22, 2023 at 21:36
0

you can fix it by checking

> where py

for example on my machine the output is

C:\Windows\py.exe

so if the py is missing and you have standard python installation then you need need to make sure that C:\WINDOWS is in the path by setting env path WINDIR=C:\WINDOWS

verify

echo %WINDIR%

if there is still no py.exe then reinstall python

0

The main answer is "Yomie" answer at top. the main problem is doskey output is not permanent and it will be undefined again if you close your command line. I combined this answer with this for better experience.

  • First add C:\Windows\System32 to system paths for working doskey. Then create a doskey file and add it py=python $* and save it for example as example: C:\bat\macros.doskey.

  • Then in your Start Menu search registry editor and go to HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\.

  • Right click and add Autorun.

  • Then right click on it and click on modify and write your doskey path example C:\bat\macros.doskey.

  • Then start your command line again and you will see that py is working again and is a permanent command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .