How do I use Homebrew installed Python as the default Python? - Stack Overflow
HomeBrew and Python installation on Mac B… - Apple Community
What are your thoughts on Homebrew for getting Python3 up and running on a Mac? And what is your preferred method on your machine?
How SHOULD you install Python on Mac OS?
As suggested by the Homebrew (executable brew) installer itself, be sure to add this to your .bashrc file or .zshrc file:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
For Apple silicon machines, the paths are slightly different. After running brew install python, you must ensure your ~/.zshrc file uses the correct Homebrew paths:
# Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
# Homebrew: Python
export PATH="/opt/homebrew/opt/python/libexec/bin:$PATH"
Results:
% which python
/opt/homebrew/opt/python/libexec/bin/python
% python --version
Python 3.9.9
% which pip
/opt/homebrew/opt/python/libexec/bin/pip
% pip -V
pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
Brew's Python interpreter changed its location again and I had to update my ~/.zshrc file to:
export PATH="$(brew --prefix)/opt/python@3/libexec/bin:$PATH"
There isn't a .../opt/python/... anymore which is annoying, because now I have to specify v3 explicitly, but at least better than having to specify the minor version like in the comments.
So far, I've worked with conda environments, installing python3 directly from the exe on the site, and homebrew. I feel like every time I use homebrew on a new computer there are SO MANY MORE PROBLEMS that I run into. Pip install fails on really simple things, brew cleanup never works, it's so frustrating...
What is the simplest way you've found to get Python3 up and running on a mac?