Skip to content
Happy Programming Guide
Start learning
Python

Python Not Working on a Mac After Installation

Installed Python on macOS and the terminal still says command not found, or runs the wrong version? python vs python3, Homebrew vs python.org, and the shell file that decides.

A person working on a laptop

On a Mac, “Python not working” after installation nearly always comes down to one of three things: you typed python and only python3 exists, the installer put Python somewhere your shell does not look, or two installations are fighting over which one runs. Each has a two-minute fix once you know which one you have.

First: try python3#

Terminal
python3 --version
python --version

macOS has not shipped a python command since the Python 2 removal. Installers from python.org create python3, and Homebrew creates python3 and version-specific names such as python3.13. If python3 works and python does not, Python is installed and working — you only need a name.

The safest fix is an alias in your shell profile:

Terminal
echo 'alias python=python3' >> ~/.zshrc
echo 'alias pip=pip3' >> ~/.zshrc
source ~/.zshrc

Inside a virtual environment, python exists automatically, so many people never need the alias at all.

Where Python went#

Terminal
which -a python3          # every python3 on the PATH, in order
ls /Library/Frameworks/Python.framework/Versions/     # python.org installer
ls /opt/homebrew/bin/python3*                          # Homebrew, Apple Silicon
ls /usr/local/bin/python3*                             # Homebrew, Intel
ls /usr/bin/python3                                    # Apple's own, tied to Xcode tools

Three different installers, three different folders. Which one runs depends on the order of your PATH, and that order is set in your shell profile.

The shell profile#

Modern macOS uses zsh, and zsh reads ~/.zshrc for every new terminal window. The python.org installer appends a line to ~/.zprofile or ~/.bash_profile; Homebrew asks you to add a line yourself. If the terminal does not see your Python, the line is missing, in the wrong file, or was added after the window opened.

Terminal
echo $SHELL               # /bin/zsh on any recent Mac
cat ~/.zshrc ~/.zprofile 2>/dev/null | grep -i python

For the python.org installer, the line should look like:

Terminal
export PATH="/Library/Frameworks/Python.framework/Versions/3.13/bin:$PATH"

For Homebrew on Apple Silicon:

Terminal
eval "$(/opt/homebrew/bin/brew shellenv)"

Add whichever applies to ~/.zshrc, then open a new terminal window. The window you were typing in still has the old PATH.

Wrong version runs#

Terminal
python3 --version           # prints 3.9 but you installed 3.13
which python3               # /usr/bin/python3 - Apple's, not yours

Apple ships an older Python with the command line developer tools, and if your installer’s folder is not ahead of /usr/bin on the PATH, Apple’s wins. The export line above fixes it by putting your folder first. Check with which -a python3: the top entry is the one that runs.

If you have both Homebrew and python.org versions, pick one and remove the other’s PATH line. Two installations with different package sets is a reliable source of “it worked yesterday” problems.

Command not found: pip#

Terminal
python3 -m pip --version
python3 -m pip install requests

Run pip through the interpreter and it always uses the matching one. Whether pip3 or pip exists as a standalone command depends on the installer; -m pip works everywhere.

“externally-managed-environment”#

Homebrew’s Python refuses pip install outside a virtual environment, with a long message that includes that phrase. It is deliberate, and the answer is a virtual environment:

Terminal
python3 -m venv .venv
source .venv/bin/activate
pip install requests

Inside the environment, python, pip and the packages you install are all yours, separate from anything the system uses.

Apple Silicon and Intel#

On an M-series Mac, a package that fails to install with an architecture error is usually being installed into an Intel Python running under Rosetta, or the reverse:

Terminal
python3 -c "import platform; print(platform.machine())"   # arm64 or x86_64

If it says x86_64 on an Apple Silicon machine, you have an Intel build. Install a native one from python.org or Homebrew and put it first on the PATH.

VS Code sees a different Python#

VS Code picks an interpreter separately from the terminal. Run Python: Select Interpreter from the command palette and choose the one you want; the status bar shows which is active. Launched from the Dock rather than a terminal, VS Code may not have read your shell profile at all, so choosing explicitly is more reliable than relying on PATH.

Questions people ask#

Should I use Homebrew or the python.org installer?

Either works. python.org gives you a specific version that stays put; Homebrew upgrades it along with everything else, which occasionally breaks virtual environments built on the old version. Beginners are usually better served by python.org.

Do I need to uninstall the old Python first?

No. Several versions coexist happily. The only thing to manage is which one is first on the PATH.

Why does python work in one terminal app but not another?

Different shells, or a window opened before the profile change. Check echo $SHELL in each and make sure the PATH line is in the file that shell reads.

Is the pre-installed Python safe to use?

For quick scripts, yes. For anything you will install packages into, use your own installation and a virtual environment.

Where to go next#

Python virtual environments: one per project, no more conflictsRead next

Keep reading

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *