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.
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 aspip
After adding the path to the System PATH variable, make sure you close and reopen any command prompts, so they use the updated PATH.
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 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:
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.
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 aspip
After adding the path to the System PATH variable, make sure you close and reopen any command prompts, so they use the updated PATH.
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 If it is still not working, as mentioned in the previous answers, then simply move up the path, as shown in the screenshot.
You get this error, because the python.exe path has not been added to the System environment variable. To do that, simply:
go to the path
C:\Users\%Username%\AppData\Local\Programs\Python\Python37-32
which contains python.execopy 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
Once you do that, close the window and simply open cmd. Type
python
and you should get something like this:
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
This happens because the path doesn't exist in environment variables.
To fix this:
- Rerun the installer
- Choose Modify
- In optional feature click "Next"
- In advanced option tick the "Add Python to environment variables"
- Install
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.
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).
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.
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
© 2022 - 2024 — McMap. All rights reserved.