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:
Add the following line to your .zshrc file:
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:
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:
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:
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):
After adding the line, restart your terminal, or run the following command in your terminal to reload the profile file:
Now, running the command python should launch the Python interpreter without any error message.
Why Python removed?
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.
- TypeError: 'NoneType' object is not subscriptable
- IndexError: string index out of range
- IndentationError: unexpected indent Error
- ValueError: too many values to unpack (expected 2)
- SyntaxError- EOL while scanning string literal
- TypeError: Can't convert 'int' object to str implicitly
- IndentationError: expected an indented block
- ValueError: invalid literal for int() with base 10
- IndexError: list index out of range : Python
- AttributeError: 'module' object has no attribute 'main'
- UnboundLocalError: local variable referenced before assignment
- TypeError: string indices must be integers
- FileNotFoundError: [Errno 2] No such file or directory
- Fatal error: Python.h: No such file or directory
- ZeroDivisionError: division by zero
- ImportError: No module named requests | Python
- TypeError: 'NoneType' object is not iterable
- SyntaxError: unexpected EOF while parsing | Python
- Unicodeescape codec can't decode bytes in position 2-3
- The TypeError: 'tuple' object does not support item assignment
- The AttributeError: 'bytes' object has no attribute 'read'