The error zsh: command not found: python
typically occurs when the Python interpreter is not correctly set in your system's PATH.
First, ensure that Python is correctly installed.
$ which python
/usr/bin/python
If no path is returned, Python may not be installed. To install Python:
$ brew install python
The system needs the correct PATH to locate Python.
$ echo $PATH
Ensure that the output includes the path to Python. If not, add it:
$ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
Afterwards, restart your shell or run:
$ source ~/.zshrc
Utilizing a version manager like pyenv can often alleviate these issues.
$ brew install pyenv
$ pyenv install 3.9.0
$ pyenv global 3.9.0
Remember to add pyenv
to the PATH if needed.
In many cases, one of these solutions should remedy the error. It's essential to understand the root cause to apply the most appropriate fix.
chsh -s /bin/bash
, and then restart your terminal.pyenv
can help manage and switch between different versions.CloneCoding
Innovation Starts with a Single Line of Code!