When installing python on MacOS, the error "zsh: command not found: python" is reported.

.Problem
homebrew install python with following command

brew install python3


Then use the following command to check the python installation version

python --version


An error will appear:

zsh: command not found: python

 2. Workaround
2.1 Add python to zsh
Add python to zsh so that it runs when the python command is typed. You can do this by running the following command in the terminal:

echo "alias python=/usr/bin/python3" >> ~/.zshrc


This will configure your zsh configuration file to run python when /usr/bin/python3 is run. If you are still having issues, make sure python=$ where the $ sign should be equal to your python installation path

2.2 Restart the terminal
or enter the following command:

source ~/.zshrc


At this point, the python command should run successfully.

 ~> python --version                                                                                    
Python 3.8.9

Guess you like

Origin blog.csdn.net/qq_27981847/article/details/132759847