How to make Mac OS use the python installed by Homebrew
macos, python, python-2.7
Solution
`brew install python` or `brew info python` output mentions:
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /opt/homebrew/opt/python@3.9/libexec/bin
So running
% echo 'export PATH=/opt/homebrew/opt/python@3.9/libexec/bin:$PATH' >> ~/.zprofile
% source ~/.zprofile
# For bash use ~/.bash_profile.
gets you those symlinks created by Homebrew - python=python3, pip=pip3 etc
% python --version
Python 3.9.10
% pip --version
pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
Problem
I have searched online for a while for this question, and what I have done so far is installed python32 in homebrew changed my .bash_profile and added the following line to it: export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH but when I close the terminal and start again, I type 'which python', it still prints: /usr/bin/python and type 'python --version' still got: Python 2.7.2 I also tried the following instruction: brew link --overwrite python or try to remove python installed by homebrew by running this instruction: brew remove python but both of the above two instructions lead to this error: Error: No such keg: /usr/local/Cellar/python can anybody help, thanks