How to Resolve "'python3' is not recognized as an internal or external command" Error in Windows
When running Python on a Windows machine, you might try to use the python3 command and receive the error: 'python3' is not recognized as an internal or external command, operable program or batch file. This error occurs because, by default, Windows Python installations do not create a python3.exe executable or alias. The standard command on Windows is simply python.
This guide will explain the command differences between Windows and other operating systems and show you the best practices for running Python on Windows, as well as how to safely create a python3 alias if you need one for cross-platform script compatibility.
Understanding the Error: Command Differences Across Operating Systems
The convention of using python3 originates from the transition period between Python 2 and Python 3 on Linux and macOS systems.
- On Linux/macOS: Systems often had both Python 2 and Python 3 installed.
pythontypically pointed to the older Python 2, andpython3was used to explicitly run Python 3. - On Windows: The Python installer for Windows typically does not follow this convention. It installs a
python.exefor the version you are installing (which is almost always Python 3 now) and apy.exelauncher for managing multiple versions.
The error simply means Windows cannot find an executable file named python3.exe in its PATH.
Solution 1: Use the Standard Windows Commands (python or py)
The simplest and most direct solution is to use the commands that Windows expects. Instead of python3, you should use python or the py launcher.
Example of command causing the error:
C:\Users\YourUser> python3 --version
'python3' is not recognized as an internal or external command,
operable program or batch file.
Solution: use python or py instead.
C:\Users\YourUser> python --version
Python 3.11.4
C:\Users\YourUser> py --version
Python 3.11.4
Using python and py is the standard, recommended practice for running Python on Windows. You should only create a python3 alias if you specifically need it for a cross-platform script or workflow.
Solution 2: Manually Create a python3.exe Alias (for Compatibility)
If you need the python3 command to work (for example, to run a shell script that was written for Linux), you can create an alias by making a copy of your python.exe file and renaming it.
Step 1: Find Your python.exe File
First, you need to locate your Python installation directory. The py launcher can tell you where the default python.exe is located.
C:\Users\YourUser> py -c "import sys; print(sys.executable)"
C:\Users\YourUser\AppData\Local\Programs\Python\Python311\python.exe
Your Python installation directory is C:\Users\YourUser\AppData\Local\Programs\Python\Python311\.
Step 2: Create a Copy Named python3.exe
Navigate to this directory in File Explorer or use the Command Prompt to create a copy of python.exe.
Solution:
# Navigate to your Python installation directory (use the path from the previous step)
C:\Users\YourUser> cd C:\Users\YourUser\AppData\Local\Programs\Python\Python311
# Create a copy of python.exe named python3.exe
C:\...Python311> copy python.exe python3.exe
1 file(s) copied.
You now have both python.exe and python3.exe in the same directory. Since this directory is (or should be) in your system PATH, Windows can now find both commands.
Do not RENAME python.exe to python3.exe.
Renaming the file will break the standard python command. You should always COPY the file to create an alias, ensuring that both python and python3 commands work correctly.
Verifying the Fix
After creating the copy, open a new Command Prompt or PowerShell window and test the python3 command.
Verification:
C:\Users\YourUser> python3 --version
Python 3.11.4
If you see the version number, your python3 alias is working correctly.
Conclusion
| Your Goal | Recommended Solution |
|---|---|
| Run Python on Windows (Standard Practice) | Use the python or py commands. |
Enable the python3 command (for cross-platform script compatibility) | Create a copy of python.exe and name it python3.exe in the same directory. |
The 'python3' is not recognized error is not a bug, but rather a result of differing command conventions across operating systems. By either using the standard Windows commands or by safely creating a python3.exe alias, you can easily resolve this issue.