I had a fresh install of macOS Sequoia and typed python3 in a fresh shell. The system found one, ran my script, and returned a version.
So far so good. Then I asked the script for sys.executable, and the answer was not the path I expected. The python3 on my PATH and the python3 Python was using were two different binaries, and the way to untangle them is the topic of this guide.
Where macOS puts Python 3
Apple ships a system Python 3 with macOS. The exact location depends on whether you installed a second Python 3 yourself and which package manager you used.
- Apple’s command-line tools Python 3 lives under /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework and exposes a python3 binary at /usr/bin/python3.
- The official python.org installer puts the framework at /Library/Frameworks/Python.framework/Versions and creates a symlink in /usr/local/bin/python3. The installer no longer touches the system /usr/bin/python3.
- Homebrew’s python formula installs to /opt/homebrew (Apple Silicon) or /usr/local (Intel) and symlinks python3 into /opt/homebrew/bin/python3 or /usr/local/bin/python3.
You can have all three on the same machine. The one your shell finds depends on the order in /etc/paths and your shell profile.
The one-line way to find the active Python 3
The most reliable check is to ask the running interpreter. The sys.executable attribute returns the absolute path of the binary that started the process. The answer you want for “where is the Python that is running my script” is on the first line of output.
python3 -c 'import sys
print(sys.executable)'
Sample output:
Pair it with the version and the prefix to get the rest of the picture in one shot.
python3 -c 'import sys, platform
print(sys.executable)
print(sys.version)
print(sys.prefix)
print(platform.mac_ver())'
Output:
/usr/bin/python3
3.9.6 (default, Aug 11 2025, 16:36:32)
[Clang 16.0.0 (clang-1600.0.26.6)]
/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9
('14.6', ('', '', ''), 'arm64')
The version line is sys.version, the prefix is the framework root, and platform.mac_ver() confirms the macOS release and the architecture.
See every Python on your PATH
For a list of every python3 your shell can resolve, use type -a. The shell walks PATH and reports every match in order.
Output on a system with the CommandLineTools Python and a Homebrew install:
python3 is /opt/homebrew/bin/python3
python3 is /usr/bin/python3
The first line is the one the shell runs when you type python3. The rest are the other matches, in PATH order. If the wrong one is on top, you have a PATH ordering problem, and the fix is below.
To see every Python binary on the filesystem, ls the directories where installers drop them. One pass covers the python.org, Homebrew, and pyenv locations at once.
ls -d /usr/bin/python3* /usr/local/bin/python3* /opt/homebrew/bin/python3* ~/.pyenv/versions/*/bin/python3 2>/dev/null
Output:
/usr/bin/python3
/opt/homebrew/bin/python3
Add –version to confirm each one is alive.
for p in /usr/bin/python3 /opt/homebrew/bin/python3
do
echo -n "$p: "
$p --version
done
Output:
/usr/bin/python3: Python 3.9.6
/opt/homebrew/bin/python3: Python 3.13.5
Use a virtual environment instead of touching the system Python
Do not pip install packages into the system Python. Apple’s framework is read-only without a sudo dance, and the system pip is pinned. The right tool is python3 -m venv, which builds a self-contained directory that owns its own Python and its own site-packages.
python3 -m venv ~/venvs/myproject
source ~/venvs/myproject/bin/activate
which python3
python3 --version
Output:
/Users/you/venvs/myproject/bin/python3
Python 3.13.5
Deactivate with deactivate. The venv directory is portable: move it, copy it, rm -rf it. Nothing it does touches the system Python.
For per-project pinned versions across multiple Python majors, pyenv is the standard answer. brew install pyenv, then pyenv install 3.12.7 in any directory, and a .python-version file picks the right one automatically.
Fix PATH order when the wrong Python is on top
If type -a python3 shows the wrong binary first, the fix is to put the directory with the version you want ahead of the others in PATH. For Homebrew on Apple Silicon, prepend /opt/homebrew/bin.
export PATH=/opt/homebrew/bin:$PATH
For Intel Macs and the python.org installer, prepend /usr/local/bin.
export PATH=/usr/local/bin:$PATH
Make the change survive a new shell by appending the line to your shell profile. The default shell on macOS Catalina and later is zsh, so use ~/.zshrc. Older shells use ~/.bashrc or ~/.bash_profile.
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
which python3
If the shell still resolves the old python3, the order in /etc/paths is overriding your profile. /etc/paths is checked before ~/.zshrc on most macOS setups, so either edit /etc/paths (needs sudo) or move the export to /etc/paths.d.
Troubleshooting common issues
Four things go wrong most often. Each is a one-line fix once you know which one you hit.
- command not found: python3 means no Python 3 is on PATH. Install the CommandLineTools with xcode-select –install, or download the python.org installer, or brew install python.
- python3 –version returns 2.7.x means a leftover Python 2 is on PATH ahead of Python 3. Either invoke python3 explicitly in your scripts, or remove the Python 2 shim from /usr/local/bin.
- pip points at the system Python after a Homebrew install means Homebrew’s site-packages directory is on sys.path but the system Python is in front. Use python3 -m pip install … to pin the install to whichever interpreter pip is being run from.
- Externally-managed-environment error on pip install means PEP 668 is doing its job. Use a venv, or pass –break-system-packages if you must have the system install. The default answer is the venv.
Frequently asked questions
How do I find the Python 3 path on macOS?
Run python3 -c ‘import sys\nprint(sys.executable)’ in Terminal. The output is the absolute path of the binary that started the interpreter. For Apple Silicon Homebrew installs this is usually /opt/homebrew/bin/python3, for Intel it is /usr/local/bin/python3, and for the CommandLineTools Python it is /usr/bin/python3.
Why is my python3 path different from the one in the Applications folder?
The Applications folder Python is the python.org framework at /Library/Frameworks/Python.framework/Versions. Its symlink lives at /usr/local/bin/python3. Applications and the symlink are the same Python, but which one runs depends on PATH order. The Applications entry does not add /usr/local/bin to PATH by default.
Should I install pip packages into the system Python on macOS?
No. The system Python is read-only without sudo, and sudo pip install on macOS is the most common way to break the CommandLineTools Python. Use python3 -m venv to create an isolated environment, then pip install into the venv.

