If you've installed Python but get "Python is not recognized as a command" in your terminal, don't worry. This is a common issue, usually caused by Python not being added to your system's PATH. Follow these steps to fix it.
Step 1: Check if Python is Installed
Open Command Prompt and type:
py --version
If you see a version number (e.g., Python 3.12), Python is installed but the command may be py instead of python. If you get an error, reinstall Python.
Step 2: Reinstall Python (with PATH enabled)
- Download the latest Python installer from python.org.
- Run the installer.
- Important: Check the box that says "Add Python to PATH" at the bottom of the installer.
- Click "Install Now" and wait for completion.
Step 3: Manually Add Python to PATH (if already installed)
If Python is already installed but still not recognized:
- Press
Win + R, typesysdm.cpl, and press Enter. - Go to the Advanced tab and click Environment Variables.
- Under System variables, find the
Pathvariable, select it, and click Edit. - Click New and add these two paths (adjust for your Python version):
C:\Python312C:\Python312\Scripts(Replace312with your version, e.g.,Python311for 3.11)
- Click OK on all dialogs.
Step 4: Restart Your Terminal
Close and reopen Command Prompt or PowerShell. Then try:
python --version
If you still have issues, restart your computer.
Additional Tips
- Use Command Prompt or PowerShell as Administrator when making PATH changes.
- If you have multiple Python versions, use
py -3.11to specify a version. - For Windows 11 users, the steps are identical to Windows 10.
Now you can run Python commands directly from any terminal. Happy coding!