The safest way to learn how to use Python on Mac is to install your own Python with a version manager and leave the macOS system Python completely alone. Recent macOS releases ship without a user-facing python, and the Python that does exist under the hood is there for Apple's tooling, not yours. Using it directly is how people end up with broken system utilities.
This guide covers a clean setup: how to install Python, how to switch between versions, and how to set a default Python version on Mac so python3 points where you expect. It's aimed at anyone using Python on a Mac for real work, from a first script to a production service.
Check what you already have
Open Terminal and run:
python3 --version
which python3
On a stock Mac you may see a path under /usr/bin/python3 — that's the Command Line Tools version, and it's fine for one-off scripts but a poor base for development. You don't want project dependencies commingling with anything the OS relies on. The goal of using Python on a Mac cleanly is to install a version you own and control.
Option 1: Homebrew (simple, single version)
Homebrew is the standard macOS package manager. If you just want a modern Python without juggling versions:
brew install python@3.13
Homebrew installs python3 and pip3 and links them onto your PATH. Verify:
python3 --version
# Python 3.13.x
Homebrew is great when you want one current Python. Its weakness is version switching — it's built to keep you on the latest, which is exactly wrong when a project pins to an older release.
Option 2: pyenv (best for switching versions)
If you work across projects that need different Python versions, pyenv is the tool. It's the cleanest answer to how to use Python on a Mac when versions vary.
brew install pyenv
Add pyenv to your shell. For zsh (the default on modern macOS), append to ~/.zshrc:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Restart your terminal, then install and use versions:
pyenv install 3.13.1
pyenv install 3.11.9
How to set the default Python version on Mac
This is where pyenv earns its keep. There are three scopes:
# Global default for your user
pyenv global 3.13.1
# Per-directory (writes a .python-version file)
pyenv local 3.11.9
# Just this shell session
pyenv shell 3.13.1
After pyenv global 3.13.1, running python and python3 anywhere resolves to that version, unless a directory has its own .python-version. That per-project pin is the feature that makes multi-project Python on a Mac painless — cd into a repo and the right interpreter is automatically active.
Always use a virtual environment per project
Never install project packages into your global Python. Create an isolated environment instead:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
The prompt changes to show (.venv) when active. Run deactivate to exit. This keeps each project's dependencies separate and reproducible, and it's the single habit that prevents the most Python headaches on macOS. Commit a lockfile (or a pinned requirements.txt) so teammates and CI resolve the exact same versions — and so a scanner can audit your dependencies. Third-party packages are where most real risk lives, and an SCA tool reads that lockfile to flag known-vulnerable versions.
A note on the JVM: how to set the Java version on Mac
Python developers on macOS often manage a JVM too — build tools, Kafka, Spark. The Mac equivalent of version switching for Java uses /usr/libexec/java_home. To set the Java version on Mac for the current shell:
/usr/libexec/java_home -V # list installed JDKs
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
java -version
Add the export line to ~/.zshrc to make it stick, or use a manager like jenv (the Java analog of pyenv) for per-project switching. The mental model is identical to Python: install what you need, pin per project, and set a sensible global default.
Keep pip and packages current
Once you're set up, keep the toolchain healthy:
pip install --upgrade pip
pip list --outdated
Outdated packages aren't just missing features — they're where known vulnerabilities accumulate. Periodically reviewing outdated dependencies (and their transitive dependencies) is part of using Python responsibly on any platform, Mac included.
FAQ
Should I ever use the built-in Python on macOS?
For a throwaway one-liner, it works. For anything you'll maintain, no. Install your own via Homebrew or pyenv so you control the version and never risk the interpreter Apple's tooling depends on.
How do I set the default Python version on Mac permanently?
With pyenv, run pyenv global 3.13.1 (substitute your version). It writes to ~/.pyenv/version and persists across sessions. A directory-level .python-version from pyenv local overrides it inside that project.
Why does python not work but python3 does?
Modern macOS and Homebrew expose python3 rather than a bare python. With pyenv installed and initialized, both python and python3 resolve to your selected version. Otherwise, alias python to python3 in your shell config.
Can I use both Homebrew Python and pyenv?
You can, but pick one as the primary for development to avoid PATH confusion. Many developers keep Homebrew for CLI tools and let pyenv own the interpreters they build against.