Python Not Recognized as a Command? Fix It on Windows, macOS, and Linux

Python Not Recognized as a Command? Fix It on Windows, macOS, and Linux

You have installed Python, opened Command Prompt or Terminal, typed python, and received an error such as:

'python' is not recognized as an internal or external command

On macOS or Linux, you may see:

command not found: python

This error usually means your computer cannot find the Python program when you type its command. Python may not be installed, or its installation folder may not be included in your system’s PATH.

The good news is that this problem is usually easy to fix. This guide explains what the error means and provides beginner-friendly solutions for Windows, macOS, and Linux.

What does “Python is not recognized as a command” mean?

When you type a command such as:

python

your operating system searches several folders for a program with that name. These folders are listed in a system setting called PATH.

If Python’s folder is missing from PATH, your computer may not know where Python is located. As a result, it cannot start the program.

There are three common causes:

Python is not installed.
Python is installed but was not added to PATH.
Your terminal was opened before Python was installed and has not loaded the updated PATH.

Before changing system settings, check whether Python is installed under a different command.

Step 1: Test the common Python commands

Open your command-line program.

On Windows, open Command Prompt or PowerShell.
On macOS, open Terminal.
On Linux, open Terminal.

Try these commands one at a time:

python --version
python3 --version

On Windows, also try:

py --version

If one command displays a version such as:

Python 3.13.5

Python is installed and working. You can use the command that worked.

For example, if python3 works, run a file with:

python3 your_file.py

If py works on Windows, run a file with:

py your_file.py

If every command produces an error, continue with the instructions for your operating system.

Fixing Python on Windows

Option 1: Install Python correctly

If Python is not installed, download the installer from the official Python website and start the installation.

On the first installation screen, look carefully for this option:

Add python.exe to PATH

Select that checkbox before clicking Install Now.

This is one of the most important steps. It allows Windows to find Python when you type python in Command Prompt or PowerShell.

After the installation finishes:

Close Command Prompt or PowerShell.
Open a new Command Prompt window.
Run:

python --version

You can also check the Python launcher:

py --version

Option 2: Repair an existing installation

If Python is already installed but the command does not work, repair the installation.

Open the Windows Start menu.
Search for Installed apps.
Find Python in the list.
Click the three-dot menu beside Python.
Select Modify.
Choose Repair if that option is available.
Restart Command Prompt.
Test the command again.

If repair does not solve the problem, modify the installation and enable the option to add Python to PATH.

Option 3: Turn off Windows App execution aliases

Sometimes Windows redirects the python command to the Microsoft Store instead of the real Python installation.

To check this:

Open Settings.
Select Apps.
Choose Advanced app settings.
Open App execution aliases.
Find the entries for python.exe and python3.exe.
Turn them off if they are redirecting the command to the Microsoft Store.
Open a new Command Prompt window.
Test:

python --version

This setting can be confusing because Windows may appear to recognize the command, but then open the Microsoft Store instead of starting Python.

Option 4: Add Python to PATH manually

If Python is installed but Windows still cannot find it, you can add its folders to PATH manually.

First, find the Python installation folder. It may be located in a folder similar to:

C:\Users\YourName\AppData\Local\Programs\Python\Python313\

You may also need the Scripts folder:

C:\Users\YourName\AppData\Local\Programs\Python\Python313\Scripts\

To add these folders:

Open the Start menu.
Search for environment variables.
Select Edit the system environment variables.
Click Environment Variables.
Under User variables, select Path.
Click Edit.
Click New.
Add the Python installation folder.
Add the Python Scripts folder.
Click OK on each window.
Close and reopen Command Prompt.

Test the installation:

python --version

Avoid copying a PATH entry from another computer. The correct folder depends on your Python version and installation location.

Fixing Python on macOS

On modern macOS systems, the command is usually:

python3

Start by checking:

python3 --version

If this displays a version, Python is available. Use python3 instead of python:

python3 script.py

You can check whether macOS can find the command with:

which python3

This displays the location of the Python executable.

Install Python on macOS

If python3 is not available, install Python using the official installer or a package manager such as Homebrew.

After installation, close Terminal and open it again. Then test:

python3 --version

If Python is installed but Terminal still cannot find it, your shell PATH may need updating. The exact file depends on your shell, commonly .zshrc for newer macOS systems.

Do not remove Apple’s system files or replace system tools manually. Use the newly installed python3 command instead.

Fixing Python on Linux

Many Linux distributions include Python 3, but the command is commonly:

python3

Test it with:

python3 --version

If it works, run your program with:

python3 script.py

If Python is missing, install it using your distribution’s package manager.

For Ubuntu or Debian-based systems, the command is usually:

sudo apt update
sudo apt install python3 python3-pip

For Fedora, the command is commonly:

sudo dnf install python3 python3-pip

For Arch Linux, use:

sudo pacman -S python python-pip

The exact package command may differ between distributions. After installation, test:

python3 --version

Should you create a python command on Linux?

Some systems only provide python3, while others also provide python. You can usually avoid changing this and simply use:

python3

This is safer because it clearly refers to Python 3.

Check whether PATH is the real problem

You can check where your computer finds Python.

On Windows:

where python
where py

On macOS or Linux:

which python3

If the command returns a file location, your computer can find Python. If it returns nothing or reports that the command cannot be found, Python is not available through your current PATH.

A simple final test

Create a file called hello.py containing:

print("Python is working correctly!")

Save it somewhere easy to find, such as your Documents folder. Open Command Prompt or Terminal in that folder and run the appropriate command:

Windows:

python hello.py

Windows Python launcher:

py hello.py

macOS or Linux:

python3 hello.py

If the message appears, your Python installation is working.

Common mistakes to avoid

Installing Python but forgetting to select Add Python to PATH on Windows.
Testing in an old terminal window after installing Python.
Using python when your system expects python3.
Installing multiple Python versions without knowing which one PATH uses.
Copying a PATH folder from another computer.
Running a file from the wrong folder.
Confusing the Python interpreter with the pip package manager.
Installing random Python files from unofficial websites.

Conclusion

The “Python is not recognized as a command” error usually means your operating system cannot locate Python. Start by testing python, python3, and py. If none work, install Python or repair the installation. Windows users should pay special attention to the Add python.exe to PATH option, while macOS and Linux users will often need to use python3.

Once the command works, create a small test file and run it. This confirms that Python is installed, your PATH is correct, and your computer is ready for Python programming.

Leave a Comment

Scroll to Top