zsh: command not found: python

The error message zsh: command not found: python that appears in the terminal when you try to run the python command, but the command is not found in your shell's PATH. In most cases, this error occurs because the system-provided Python 2 installation has been removed from Apple's macOS as of macOS 11 Big Sur. Or in some other cases, Python is not installed or that its executable file is not in the system's PATH.

Python 2 installation has been removed from macOS

This error occurs because the system-provided Python 2 installation has been removed from Apple's macOS as of macOS 11 Big Sur.

When Apple removed the system-provided Python 2 installation, it impacted users who were relying on it for their Python development environment. As a result, they may have encountered the error message zsh: command not found: python when trying to run the python command.

To resolve this issue, you need to install a newer version of Python (such as Python 3 ) or use a version manager like Homebrew or pyenv to manage your Python installations. These tools allow you to install multiple versions of Python and switch between them as needed.

How to install Python using Homebrew:

Open your terminal and run the following command:

brew install python

Add the following line to your .zshrc file:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Reload your terminal or run source ~/.zshrc to apply the changes.

After installation, you can verify that Python is installed by running the following command in your terminal:

python --version

With Python installed, you should no longer see the error message zsh: command not found: python when trying to run the python command.

Python is not installed or executable not in the system's PATH.

Check if Python is installed: Open a terminal and run the following command:

python --version

If the output shows the version of Python, it is installed on your system. If you receive the same error message, Python is not installed.

Install Python:

If Python is not installed, you can install it by following the instructions for your operating system. On a Debian-based system, you can run the following command:

sudo apt-get install python

Update PATH:

If Python is installed, but its executable is not in the PATH, you can add it to the PATH. You can do this by adding the following line to your shell profile file (e.g. ~/.zshrc):

export PATH="$PATH:/usr/bin/python"

After adding the line, restart your terminal, or run the following command in your terminal to reload the profile file:

source ~/.zshrc

Now, running the command python should launch the Python interpreter without any error message.

Why Python removed?


how to solve zsh: command not found: python

Apple removed the system-provided Python 2 installation from macOS 11 Big Sur because Python 2 has reached its end of life. This means that the Python development community is no longer actively supporting Python 2, and it is no longer considered a secure or reliable version of the language.

To encourage users to transition to a newer and more secure version of Python, Apple decided to remove the system-provided Python 2 installation from its latest operating system. Instead, users can install a newer version of Python, such as Python 3, or use a version manager like Homebrew or pyenv to manage their Python installations.

By removing the system-provided Python 2 installation, Apple is helping to ensure that its users are using a secure and reliable version of the language for their development projects.