macOS

How to Update Python on macOS to the Latest Version: Complete Guide

The default Python on macOS is outdated and not intended for development. This guide helps you install the latest Python 3 via Homebrew or pyenv, configure environment variables correctly, and avoid conflicts with system files.

Updated at February 14, 2026
15-30 min
Medium
FixPedia Team
Применимо к:macOS Sonoma 14macOS Ventura 13macOS Monterey 12Python 3.12+

Why the Default Python on macOS Isn't Suitable for Development

When you buy a Mac, you get a pre-installed version of the Python interpreter. However, this version:

  1. Is outdated. Apple rarely updates the system Python, and it almost always lags several major versions behind the current release from the Python Software Foundation.
  2. Is locked from modification. The system Python resides in the protected system folder (/usr/bin/). You cannot update it via a package manager or directly, as this would require disabling SIP (System Integrity Protection) and would break macOS.
  3. Is not for development. It is intended solely for the internal needs of the operating system. Installing third-party packages via pip into the system Python is impossible or will lead to conflicts.

The correct approach: Install a separate, up-to-date version of Python 3 alongside the system one using a package manager. This is safe and gives you full control.

Homebrew is the standard package manager for macOS. It installs packages into its own directory (/opt/homebrew/ on Apple Silicon or /usr/local/ on Intel), leaving the system untouched.

Step 1: Install Homebrew (if not already installed)

Open Terminal (in Applications -> Utilities or via Spotlight) and run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the on-screen instructions. After installation, Homebrew may suggest adding itself to your PATH. Do so by following the instructions at the end of the install (usually adding a line to ~/.zprofile).

💡 Tip: Verify the installation by running brew doctor. It will report any configuration issues.

Step 2: Install Python

Now install Python. Homebrew will install not only the interpreter itself but also the pip package manager, python@3.x utilities, and create a python3 symlink in its bin directory.

brew update
brew install python

This command will install the latest stable version of Python 3 (e.g., 3.12.x).

Step 3: Configure the PATH

This is the most important step; without it, your system will continue using the old Python.

  1. Determine which shell you are using. Run echo $SHELL. If the path ends with zsh (the default in macOS Catalina and newer) — edit ~/.zshrc. If it ends with bash — edit ~/.bash_profile or ~/.bashrc.
  2. Open the corresponding file in a text editor (e.g., nano ~/.zshrc).
  3. At the very top of the file, add the line:
    export PATH="/opt/homebrew/bin:$PATH"
    
    • For an Intel-based Mac, the path may be /usr/local/bin:$PATH.
  4. Save the file (in nano, this is Ctrl+X, then Y, then Enter).
  5. Apply the changes to your current Terminal session:
    source ~/.zshrc  # or source ~/.bash_profile
    

Step 4: Verify the Installation

Run the commands:

python3 --version
# Expected output: Python 3.12.x

which python3
# Expected output: /opt/homebrew/bin/python3 (or /usr/local/bin/python3)

# Check what 'python' points to by default (if you created a symlink, see below)
python --version 2>/dev/null || echo "Command 'python' not configured"

If which python3 shows a path inside /opt/homebrew/ or /usr/local/, and not /usr/bin/, you're on the right track.

(Optional) Create a python command

For historical reasons, many scripts and instructions use the python command instead of python3. Homebrew does not create a python symlink by default to avoid conflicting with the system Python.

If you want the python command to invoke your new Python, create a symlink:

brew link --overwrite python

⚠️ Important: This command will create a symbolic link python in /opt/homebrew/bin/. Since you added this path to the beginning of your PATH, your python command will now point to the Homebrew version. Ensure this is what you want.


Method 2: Version Management with pyenv (For Advanced and Multi-Project Environments)

If you need to frequently switch between different Python versions (e.g., Python 3.10 for one project, 3.12 for another), use pyenv.

Step 1: Install pyenv via Homebrew

brew install pyenv

Step 2: Configure pyenv in your shell

pyenv works by shimming the python command in your current shell. To do this, you need to add its initialization to your shell configuration file (~/.zshrc or ~/.bash_profile).

Add the following lines to the end of the file:

# pyenv configuration
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init --path)"
  eval "$(pyenv init -)"
  eval "$(pyenv virtualenv-init -)"  # if you plan to use virtual environments
fi

Run source ~/.zshrc.

Step 3: Install a Specific Python Version

# List available versions for installation
pyenv install --list | grep -E "^\s*3\.(10|11|12)"

# Install the desired version (e.g., 3.12.3)
pyenv install 3.12.3

# Install another (e.g., 3.10.13)
pyenv install 3.10.13

Step 4: Set a Global or Local Version

  • Globally (default for all projects):
    pyenv global 3.12.3
    
  • Locally (only for the current project directory):
    cd /path/to/your/project
    pyenv local 3.10.13
    
    This creates a .python-version file in the project folder, and pyenv will automatically switch the Python version when you navigate into it.

Step 5: Verification

python --version
# Should display the version installed via pyenv (e.g., 3.12.3)

pyenv versions
# Will show all installed versions and the currently active one (*)

Setting Up Virtual Environments (The Essential Next Step)

Once you have your system Python set up, you will quickly face the task of isolating dependencies between projects. Never install packages globally (pip install package) into your main Python!

Use virtual environments:

  1. Built-in venv (recommended):
    # Create an environment in a .venv folder
    python3 -m venv .venv
    
    # Activate it (in zsh)
    source .venv/bin/activate
    
    # Now pip install will install packages only into this environment
    pip install requests
    
    # Deactivate
    deactivate
    
  2. Management via pyenv-virtualenv (if you installed pyenv):
    # Create a virtual environment based on a specific Python version
    pyenv virtualenv 3.12.3 myproject-env
    
    # Activate it for the current folder
    pyenv local myproject-env
    

Verification and Next Steps

  1. Check your PATH. The command which -a python3 should show a path in /opt/homebrew/bin/ or ~/.pyenv/shims/ above /usr/bin/.
  2. Upgrade pip. Even a fresh Python install might have an outdated pip. Run:
    python3 -m pip install --upgrade pip setuptools wheel
    
  3. Install a dependency manager. For most projects, you will need poetry or pipenv. Install them globally into your new Python:
    python3 -m pip install poetry
    
  4. Remove old versions (optional). If you previously installed Python via other methods (e.g., from python.org), you can remove them to avoid confusion. They are typically located in /Library/Frameworks/Python.framework/.

You have successfully updated Python on macOS! You now have a modern, managed interpreter ready for development with Django, FastAPI, data analysis, or automation.

F.A.Q.

Why update Python on macOS if it's already installed?
Can I remove the system Python and replace it with a new one?
Which is better: Homebrew or pyenv for installing Python?
After installing via Homebrew, the `python` command still runs the old version. What to do?

Hints

Install Homebrew (if not already installed)
Install Python via Homebrew
Configure the PATH variable
Verify the installation
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community