The Python executable is not recognized on Windows 10 [duplicate]
Asked Answered
O

10

29

I recently installed Python 3.6.3 on my device. When I type python in my cmd window, it gives me this error. I do have the PATH in the environment variables. Path Lists. This should normally fix it, but python is still not recognized.

Overawe answered 28/11, 2017 at 19:13 Comment(1)
"I do have the PATH in the environment variables." It needs to be before the Microsoft Apps path, not after, because the path is searched in order. Otherwise, this is the same problem as when the PATH hasn't been set, so this is a duplicate.Lowgrade
I
39

The path to the Python executable needs to be in the System PATH variable. Note this is not the User PATH variable.

The OP had Python 3.6.3 installed in C:\Python\Python36-32, however a common default location for installation is in the users AppData\Local\Programs\ folder. This post will assume a Python 3.10 installation in this location. Please adjust as needed for your current Python version and path.

You can confirm the path from the command prompt by checking the Python executable directly from the folder.

cd %LOCALAPPDATA%\Programs\Python\Python310
python --version

This should print the Python interpreter version. For example, Python 3.10.4.

Add the following entries to the System PATH:

  • %LOCALAPPDATA%\Programs\Python\Python310 for the python executable
  • %LOCALAPPDATA%\Programs\Python\Python310\Scripts for tools such as pip

After adding the path to the System PATH variable, make sure you close and reopen any command prompts, so they use the updated PATH.

Improvisation answered 28/11, 2017 at 19:45 Comment(2)
Thank You. How do you change the path from USER to System?Overawe
In your screenshot, you see an Edit environment variable window. Behind that in the screenshot is the Environment Variables window which is divided into two sections. The top section is the User section. The bottom section is the System section. Edit the PATH variable in the System section.Improvisation
M
65

I had the same problem, due to a stupid decision from Microsoft.

I had another line in my system path variable: C:\Users\MyUserName\AppData\Local\Microsoft\WindowsApps

And Windows 10 put a python.exe file there that only redirected me to the Python page of the Microsoft Store:

Enter image description here

Since this line was above my true Python path, typing python in the cmd prompt opened the Microsoft Store...

Solution:

Type App execution aliases in the Windows 10 search bar, and then uncheck the aliases for python.exe and python3.exe. More information is here.

Mckinnon answered 9/3, 2021 at 12:41 Comment(3)
Just tested the alias settings - no effect in Win11 Pro 22000.708 - gets forcefully re-enabled the same nanosecond you turn it off (both python.exe and python3.exe, but not any others). Works on Win10 Pro without issue, even without Python installed at all.Loki
My exact same problem. I was going nuts trying to figure it out, thanks for posting it. Note, for me only this worked, not changing path priorities or moving paths around as others have suggested.Foch
@afk5min I had the same problem on Win10. Turns out you need to close all the apps and programs that use Python. For me it was PyCharm. After that, re-enabling went awaySwarthy
I
39

The path to the Python executable needs to be in the System PATH variable. Note this is not the User PATH variable.

The OP had Python 3.6.3 installed in C:\Python\Python36-32, however a common default location for installation is in the users AppData\Local\Programs\ folder. This post will assume a Python 3.10 installation in this location. Please adjust as needed for your current Python version and path.

You can confirm the path from the command prompt by checking the Python executable directly from the folder.

cd %LOCALAPPDATA%\Programs\Python\Python310
python --version

This should print the Python interpreter version. For example, Python 3.10.4.

Add the following entries to the System PATH:

  • %LOCALAPPDATA%\Programs\Python\Python310 for the python executable
  • %LOCALAPPDATA%\Programs\Python\Python310\Scripts for tools such as pip

After adding the path to the System PATH variable, make sure you close and reopen any command prompts, so they use the updated PATH.

Improvisation answered 28/11, 2017 at 19:45 Comment(2)
Thank You. How do you change the path from USER to System?Overawe
In your screenshot, you see an Edit environment variable window. Behind that in the screenshot is the Environment Variables window which is divided into two sections. The top section is the User section. The bottom section is the System section. Edit the PATH variable in the System section.Improvisation
A
11

If it is still not working, as mentioned in the previous answers, then simply move up the path, as shown in the screenshot.

Image here

Adjournment answered 28/12, 2019 at 10:52 Comment(2)
I moved the system path (not user path) to the top and it worked.Autochthon
thank you, that's correct the problem for meOligosaccharide
K
3

You get this error, because the python.exe path has not been added to the System environment variable. To do that, simply:

  1. go to the path C:\Users\%Username%\AppData\Local\Programs\Python\Python37-32 which contains python.exe

  2. copy the path and open System environment variables and in the variable section look for variable called Path. If not, create a new variable with Variable Name as Path and value as the copied path

    Enter image description here

  3. Once you do that, close the window and simply open cmd. Type python and you should get something like this:

    Enter image description here

Knawel answered 10/2, 2019 at 15:56 Comment(0)
L
3

If you are trying to install the new Python version, python-3.9.6, then click the checkbox of Add Python 3.9 to PATH

Enter image description here

Longways answered 6/7, 2021 at 15:25 Comment(0)
S
3

This happens because the path doesn't exist in environment variables.

To fix this:

  1. Rerun the installer
  2. Choose Modify
  3. In optional feature click "Next"
  4. In advanced option tick the "Add Python to environment variables"
  5. Install
Servais answered 17/12, 2021 at 10:49 Comment(0)
S
2

All the answers on Stack Overflow_ about it were obsolete, so I decided to add this. The path variable that needs to be added is,

C:\Users\Username\AppData\Local\Programs\Python\Python36-32

Note that everyone may have a different Username.

Sublimation answered 5/2, 2018 at 13:48 Comment(4)
This depends on the location the user chooses to install python. The accepted answer used the OPs install location.Improvisation
I agree with you.Sublimation
Turns out the problem was related to a system vs user path.Overawe
This answer helped me; I had unknowingly installed python in this directory instead of the usual directoryShabby
C
2

If you are working with the command prompt and if you are facing the issue even after adding the Python path to system variable PATH:

Remember to restart the command prompt (cmde.exe).

Coquille answered 26/4, 2020 at 15:22 Comment(0)
I
1

I too was struggling with this issue, and everything was configured correctly. I installed and setup my system path variables as one would. And everything was fine. Then upon reboot windows would not recognize 'python' as a command as if it were unaware of the path variable. Double checked to confirm everything was still setup correctly (it was).

It only started to work again after I manually browsed to the directory in which python.exe existed, and ran 'python'. After that windows seemed to recognize my path variable and I could call 'python' from where ever need be. Very odd. Figured I'd share in case someone else runs into this.

Interception answered 11/8, 2018 at 15:43 Comment(0)
V
0

For Python 3.6, there are actually two path entries. Also, it's best to use the %USERPROFILE% rather than hard coding it.

%USERPROFILE%\AppData\Local\Programs\Python\Python36 %USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts

Voiced answered 19/3, 2018 at 16:39 Comment(2)
%USERPROFILE% only applies if that's where you are installing. This would not work for custom paths. The OP had python installed in c:\Python\Python36-32Improvisation
Guys I still cannot get this to install on my new W10 Pro -- will recognize a (broken) pip, not python. I hate Windows.Applecart

© 2022 - 2024 — McMap. All rights reserved.