What the Error 'python' is Not Recognized Means
The error 'python' is not recognized as an internal or external command, operable program or batch file appears in the Windows command line (CMD or PowerShell) when attempting to run the python command. The system cannot locate the python.exe executable file in the current folder or in the folders specified in the PATH environment variable. As a result, the python command is not available globally.
The error usually occurs immediately after installing Python or when using a new terminal without restarting the system.
Common Causes
- Python is not installed — the program is missing from the system.
- Python is installed but not added to PATH — the "Add Python to PATH" option was not selected during installation.
- The Python path in PATH is incorrect — for example, after updating Python, the path changed but the old entry remains.
- PATH changes have not taken effect — after adding the path, the command line or computer was not restarted.
- Python was installed for a single user — the path was added only to the user's environment variables, and you are working from a different account.
Solutions
Solution 1: Manually Add Python to the PATH Variable
This is the primary and most reliable method. You will manually tell the system where to find python.exe.
- Locate the Python installation folder
Open File Explorer and navigate to:C:\Users\<Your_username>\AppData\Local\Programs\Python\
Here you will see one or more folders with Python versions (e.g.,Python39,Python310). Note the path to the desired version. You will also need theScriptssubfolder inside this folder. - Open the Environment Variables editor
PressWin + R, typesysdm.cpl, and press Enter.
Go to the "Advanced" tab → click "Environment Variables". - Add paths to the
Pathvariable
In the "System variables" section (or "User variables" if Python is installed only for you), find thePathvariable and select "Edit".
Click "New" and add two paths:- The path to the Python folder (e.g.,
C:\Users\Иван\AppData\Local\Programs\Python\Python39) - The path to the
Scriptsfolder (e.g.,C:\Users\Иван\AppData\Local\Programs\Python\Python39\Scripts)
- The path to the Python folder (e.g.,
- Apply the changes
Click "OK" in all windows. - Restart the command line
Close all open CMD/PowerShell windows and open them again. - Verify the command works
Type:python --version
If you see the Python version (e.g.,Python 3.9.7), the error is resolved.
⚠️ Important: If you have multiple Python versions, add only one to
PATH(the one you want to use by default), otherwise the system may run the wrong version.
Solution 2: Reinstall Python with Automatic PATH Addition
If you prefer not to configure PATH manually, reinstall Python and be sure to check the appropriate box.
- Download the Python installer from the official website.
- Run the installer.
- At the bottom of the installation window, check the box "Add Python to PATH" — this is critical.
- Select "Customize installation" (if you need to configure components) or "Install now" for a standard installation.
- Wait for completion.
- Restart the command line and verify with
python --version.
Solution 3: Run Python Using the Full Path (Temporary Workaround)
If you need to run a script urgently and configuring PATH is not an option, use the full path to the executable.
For example:
"C:\Users\Иван\AppData\Local\Programs\Python\Python39\python.exe" script.py
This method does not require administrator privileges or system changes, but it is inconvenient for regular use.
Prevention
- Always check "Add Python to PATH" during installation — this prevents the issue.
- When updating Python to a new version, check your PATH — the old path may point to a removed version. Remove outdated entries from the
Pathvariable. - Avoid moving the Python folder after installation — if you move it, PATH becomes invalid. It's better to reinstall Python in the desired location.
- Regularly check PATH for non-existent paths using
echo %PATH%(CMD) or$Env:Path(PowerShell).