cmd prompt does not recognizes python command on Windows 7

eryk sun eryksun at gmail.com
Wed Aug 10 15:03:05 EDT 2016


On Wed, Aug 10, 2016 at 1:46 PM, BartC <bc at freeuk.com> wrote:
> On 10/08/2016 11:34, eryk sun wrote:
>>
>> On Wed, Aug 10, 2016 at 4:46 AM,  <sh.ajay12 at gmail.com> wrote:
>>>
>>> i have installed python 3.5 , but the python command is not recognized
>>>
>>> C:\Users\sharmaaj>python
>>> 'python' is not recognized as an internal or external command,
>>> operable program or batch file.
>>>
>>> what should i do to run python commands.
>>
>> Modify your setup. Open "Programs and Features" from the control
>> panel. Right-click the entry for Python 3.5 (not "Python Launcher")
>> and select Uninstall/Change. In the dialog, click on "Modify". Click
>> "Next" and select "Add Python to environment variables". Click
>> "Install". When it's done, open a new command prompt and enter
>> "python".
>
> That's an unusual way of doing it. And rather precarious as you're one wrong
> click away from deleting Python altogether!
>
> It also, after doing the above, spent rather a long time copying files about
> when the operation shouldn't need anything of the sort.
>
> However, I tried it and it didn't seem to work (opening a new prompt and
> type 'python'). Maybe it needs a machine restart, but I can't be bothered to
> try that on the off-chance it might work.

I did test that it works -- using the Python 3.5 installer, which was
completely rewritten. It adds Python's installation and Scripts
directories to PATH, and it doesn't need a reboot because the
installer broadcasts a WM_SETTINGCHANGE "Environment" message that
causes Explorer to reload its environment from the registry (the old
installer doesn't do this).

As to the procedure being unusual, I thought it would be simpler and
more reliable than editing PATH in the old control-panel environment
variable editor, which can be much worse if the user messes it up.
Windows 10 has an improved editor that splits the value into separate
text boxes and makes it easy to add entries and move them around, but
most people are still using Windows 7.

Also, the default installation path for a per-user installation of
Python 3.5 is in the hidden folder
"%LOCALAPPDATA%\Programs\Python\PythonXY[-32]". This can be difficult
for users to find without inspecting the start-menu shortcuts or
running `py -c "import sys;print(sys.prefix)"` -- assuming they used
the default all-users installation of the py launcher to even be able
to run py.exe.



More information about the Python-list mailing list