To install Python on a Mac with Homebrew, run:
brew install python
Then open a new Terminal window and check it with python3 --version. The command you use is python3, not python, and the Python you get is whatever Homebrew currently calls “python”, which is not always the version you expect.
I checked all of this on a MacBook Air M3 running macOS Tahoe 26.6.2 with Homebrew 7.0.11. I did not run the install itself on the test Mac (the rules for this site forbid installs there), so the parts below that come from brew info are marked as such. Everything else was run and pasted as-is.
Step 1: see which Python you already have
Before you install anything, look at what your Mac already runs:
which -a python3 python pip3 pip
python3 --version
On my Mac, with no Homebrew Python installed, the output was:
/usr/bin/python3
/usr/bin/pip3
Python 3.9.6
That /usr/bin/python3 is not a “real” Python that ships with macOS. It is a small stub. The first time you run it, macOS offers to install the Xcode Command Line Tools. Once they are installed, the stub runs this Python:
/usr/bin/python3 -c 'import sys; print(sys.prefix)'
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9
So on macOS Tahoe 26.6.2, the Apple Python is still 3.9.6. That version is old and Apple controls its updates. It is fine for tiny scripts, but for real projects you want your own copy. That is what Homebrew gives you.
Note what is missing from the first output: there is no plain python command at all.
zsh:1: command not found: python
Step 2: check what brew install python will give you
“python” in Homebrew is an alias, not a version. Ask Homebrew what it points to today:
brew info python
The first line on my Mac:
==> python@3.15: stable 3.15.2 (bottled)
The JSON form shows the full alias list and what gets pulled in:
brew info --json=v2 python | python3 -c 'import sys,json; d=json.load(sys.stdin)["formulae"][0]; print(d["name"], d["aliases"]); print(d["dependencies"])'
python@3.15 ['python', 'python3', 'python@3']
['ca-certificates', 'mpdecimal', 'openssl@4', 'sqlite', 'xz', 'zstd']
So brew install python, brew install python3 and brew install python@3 all install the same formula. When Homebrew moves the alias to a newer version, the same command gives you a different Python. If your project needs a fixed version, name it.
Here is what each formula was at on the day I tested (from brew info):
| Formula | Stable version | Note |
|---|---|---|
python@3.15 | 3.15.2 | what python / python3 points to |
python@3.14 | 3.14.10 | |
python@3.13 | 3.13.18 | |
python@3.12 | 3.12.16 | |
python@3.11 | 3.11.18 | |
python@3.10 | 3.10.22 | marked deprecated |
Step 3: install a specific Python version
To install one exact minor version:
brew install python@3.12
This is the step people trip over. A versioned formula does not give you a python3 command. Its caveats (from brew info python@3.12) say:
Python is installed as
$HOMEBREW_PREFIX/bin/python3.12
Compare that with the default formula, whose caveats say:
Python is installed as
$HOMEBREW_PREFIX/bin/python3
I checked 3.12, 3.13 and 3.14: all three install only python3.12, python3.13 or python3.14 into /opt/homebrew/bin. Only the formula behind the python alias links python3. That is why, after brew install python@3.12, running python3 --version can still print Python 3.9.6. Your new Python is there; you just have to call it by its full name:
python3.12 --version
If you want python and python3 to mean 3.12 in your shell, the caveats point to a folder with unversioned links:
export PATH="$(brew --prefix)/opt/python@3.12/libexec/bin:$PATH"
Put that line in ~/.zprofile to make it stick. I did not edit shell files on the test Mac. The guide on setting environment variables permanently explains which file to use and why.
Step 4: make sure Terminal finds Homebrew’s Python first
On Apple Silicon, Homebrew lives in /opt/homebrew. On Intel Macs it is /usr/local. Check yours:
brew --prefix
uname -m
/opt/homebrew
arm64
After installing, run which -a python3 again. The Homebrew path should be listed before /usr/bin/python3. If /usr/bin/python3 comes first, or brew itself is “command not found”, your PATH is missing Homebrew’s shell setup. The fix is in zsh: command not found: brew.
Also remember that an open Terminal window keeps its old command lookup. Open a new window, or run rehash in zsh, after you install.
Step 5: use a virtual environment for pip
Homebrew’s Python is meant for Homebrew. Per Homebrew’s own Python docs, running pip install into it directly is blocked (you get an “externally-managed-environment” error). I did not test that error here because Homebrew Python was not installed. The fix is the same either way: give each project its own virtual environment.
I created one with the system Python to show what it looks like:
python3 -m venv .venv
source .venv/bin/activate
which python python3 pip
python --version
.../demo/.venv/bin/python
.../demo/.venv/bin/python3
.../demo/.venv/bin/pip
Python 3.9.6
(I shortened the long temporary-folder path to ....)
Two things to notice:
- Inside the venv, plain
pythonandpipwork, even thoughpythondoes not exist outside it. - The venv uses whichever Python created it. With Homebrew Python, run
python3.12 -m venv .venv(orpython3 -m venv .venvfor the default) to pick the version.
My system-Python venv came with pip 21.2.4, which is very old. Run pip install --upgrade pip inside a fresh venv before installing packages.
Type deactivate to leave the venv. Afterwards, which python printed python not found again.
Common questions
Why does python say “command not found” after I installed Python?
Homebrew does not put an unversioned python in /opt/homebrew/bin. Use python3, use python inside a virtual environment, or add the formula’s libexec/bin folder to your PATH as shown in step 3.
I installed python@3.12 but python3 --version still shows 3.9.6. Why?
Versioned formulas only install python3.12. python3 still resolves to the Apple stub at /usr/bin/python3. Call python3.12 directly, or add $(brew --prefix)/opt/python@3.12/libexec/bin to the front of your PATH.
Should I remove the system Python?
No. /usr/bin/python3 belongs to macOS and is protected. Homebrew’s Python sits next to it. PATH order decides which one runs.
Should I use pyenv or uv instead?
If you switch between many Python versions per project, a version manager such as pyenv or uv is easier than several python@3.x formulas. Neither was installed on the test Mac, so I have not compared them here. For one or two versions, Homebrew is enough.
How do I uninstall Homebrew’s Python?
Run brew uninstall python@3.15 (or the version you installed). Other formulas may depend on it, so check first. The Homebrew uninstall guide covers brew uses --installed and cleanup.