Fix Python Not Recognized as Internal or External Command
In this article
If you see “Python is not recognized as an internal or external command” when typing python in Command Prompt or PowerShell, the fix is to add the Python installation folder to your Windows PATH environment variable. This article explains why the error occurs and gives step-by-step instructions to resolve it on Windows 10 and 11.
What Causes the Error
The error message appears when Windows cannot find the python.exe executable in any of the folders listed in the PATH environment variable. When you type a command in the terminal, Windows searches each directory in PATH in order. If the Python folder is not there, the command fails with this exact message. This commonly happens because:
- Python was installed without selecting the “Add Python to PATH” checkbox during installation.
- The PATH variable was modified after installation, accidentally removing the Python entry.
- You installed Python for a different user or in a custom location that is not in your user PATH.
- You are using a virtual environment or a Python distribution that is not properly configured.
How to Check if Python Is Installed
Before editing PATH, verify that Python is actually installed. Open File Explorer and navigate to a common installation location, such as C:\Python3x or C:\Users\YourName\AppData\Local\Programs\Python\Python3x. If you find a folder containing python.exe, Python is installed. Alternatively, try the full path in the terminal: type C:\Path\To\python.exe --version (replace with your actual path). If that works, the issue is purely a PATH problem.
How to Add Python to PATH on Windows
Here are the steps to add Python to your PATH environment variable:
- Open the Start menu, type “environment variables” and select “Edit the system environment variables”.
- In the System Properties window, click “Environment Variables…” at the bottom.
- In the “User variables” section (or “System variables” if you have admin rights), select the variable named
Pathand click “Edit”. - Click “New” and add the full path to your Python installation folder (e.g.,
C:\Python312). Also add theScriptssubfolder (e.g.,C:\Python312\Scripts) to access pip and other tools. - Click “OK” on all windows to save changes.
- Close and reopen your terminal. Type
python --versionto test.
If you don’t see a Path variable, create a new one with the name Path and add the Python folder as its value.
Alternative Fixes for Common Scenarios
If adding to PATH doesn’t work, try these alternatives:
- Reinstall Python with the PATH option: Run the installer again, choose “Modify”, and ensure the “Add Python to PATH” checkbox is checked.
- Use the full path: Instead of
python, type the full path to python.exe every time. This is not convenient but works as a temporary workaround. - Use the Python launcher: On Windows, the command
pyis often available even ifpythonis not. Trypy --versionandpy script.py. - Check for multiple Python installations: If you have both the Microsoft Store version and the official python.org version, PATH conflicts can occur. Uninstall one or adjust the order in PATH.
Understanding PATH and Environment Variables
PATH is a list of directories that Windows searches when you run a command without a full path. Each directory is separated by a semicolon. When you install Python, the installer can add its directory to PATH automatically, but if you skip that step, you must do it manually. Environment variables are stored in the Windows registry and can be set per-user or system-wide. User variables apply only to your account; system variables apply to all users. Editing system variables requires administrator privileges.
Common Mistakes and Misconceptions
One common mistake is adding the wrong path. For example, adding C:\Users\YourName\AppData\Local\Programs\Python instead of the specific version folder like Python312. Another is forgetting to add the Scripts folder, which prevents pip from working. Also, after changing PATH, you must open a new terminal window; existing windows keep the old PATH. Some users think the error means Python is not installed, but it often is installed—just not in PATH. Finally, be careful not to delete existing PATH entries when editing; use the “New” button to add, not overwrite.
Frequently Asked Questions
Why does “python” work in one terminal but not another?
Each terminal window reads PATH when it starts. If you changed PATH after opening the terminal, the old window still uses the old PATH. Close and reopen the terminal to pick up the change. Also, some terminals (like VS Code) may need a full restart.
What is the difference between “python” and “py”?
“py” is the Python launcher for Windows, which is installed with Python from python.org. It can run multiple Python versions and is often available even if “python” is not in PATH. Use py as a fallback.
Do I need to add both the Python folder and the Scripts folder?
Yes, adding the Scripts folder is important because it contains pip, the package installer. Without it, you can run Python but not pip commands like pip install.
Can I fix this without admin rights?
Yes, you can edit the user PATH variable without admin rights. The steps are the same, but choose the “User variables” Path instead of the system one. This will work for your user account only.
Why did the error appear after I updated Python?
When you update Python, the installer may change the installation folder (e.g., from Python311 to Python312) and update PATH accordingly. If the installer fails to update PATH, the old path becomes invalid and the error appears. Re-add the new path or reinstall with the PATH option.
Is there a command to add Python to PATH from the command line?
Yes, you can use the setx command, but it has limitations. For example, setx PATH "%PATH%;C:\Python312" adds the folder, but it may truncate the PATH if it’s too long. It’s safer to use the GUI method for most users.