Fixing "Python Not Recognized" Issue in Windows
If you've encountered the error "Python is not recognized as an internal or external command" while trying to run Python from the command prompt in Windows, don't worry—it's a common issue. This happens when Python's installation path is not added to the system's environment variables. In this blog post, we'll go through multiple ways to fix this issue.
1. Check If Python Is Installed
Before troubleshooting, ensure that Python is actually installed on your system:
- Open Command Prompt (Win + R, type
cmd
, and hit Enter). - Type the following command:
orpython --version
py --version
- If you see an error message, Python might not be installed. Download it from python.org and install it.
2. Add Python to System Environment Variables
If Python is installed but not recognized, you need to add it to the system’s PATH.
Method 1: During Installation
- Download Python from python.org.
2.Run the installer and check the box that says "Add Python to PATH" before clicking "Install Now".
Method 2: Manually Adding Python to PATH
If Python is already installed but not recognized, follow these steps:
- Locate your Python installation path. It is usually:
C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX
- or
C:\PythonXX
(for older versions)
- Copy the path to the clipboard.
- Add the path to the environment variables:
- Press Win + R, type
sysdm.cpl
, and press Enter. - Go to the Advanced tab and click Environment Variables or open search and enter environment it will show like the above image click on it.
- Under System Variables, find and select Path, then click Edit.
- Click New, paste your Python path, and press OK.
- Also, add the
Scripts
folder (inside the Python installation directory), e.g.,C:\Users\YourUsername\AppData\Local\Programs\Python\PythonXX\Scripts like present in the above image.
- Click OK on all windows and restart your computer.
- Press Win + R, type
3. Verify the Fix
After restarting, open Command Prompt and type:
python --version
If it returns the Python version, the issue is resolved!
4. Alternative: Use the Python Launcher
Windows comes with a Python launcher (py
), which might work even if python
is not recognized. Try running:
py --version
If it works, you can use py
instead of python
in your commands.
5. Reinstall Python
If nothing else works, uninstall and reinstall Python with the "Add Python to PATH" option enabled. Make sure to remove the old installation completely before reinstalling.
Conclusion
The "Python not recognized" error is usually due to a missing PATH configuration. Following the steps above should resolve the issue. Happy coding!
0 Comments