Install Python on macOS

macOS comes with Python pre-installed, but it’s an older version managed by Apple. For development, you should install the latest Python version.

Using Homebrew (Recommended)

Homebrew is the easiest way to install Python on macOS.

Install Homebrew

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

Install Python

brew install python

This installs the latest Python and automatically adds it to your PATH.

Using Pyenv for Multiple Versions

If you need multiple Python versions, Pyenv is the best solution.

Install Pyenv with Homebrew

brew install pyenv

Configure Shell

Add to your ~/.zshrc or ~/.bash_profile:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Install Python Versions

pyenv install 3.12.0
pyenv install 3.11.0
pyenv global 3.12.0

Using Official Installer

You can also download the official installer from python.org:

  1. Visit python.org/downloads/
  2. Download the latest macOS installer
  3. Double-click the .pkg file
  4. Follow the installation prompts

Verify Installation

python3 --version
pip3 --version

Virtual Environment Setup

python3 -m venv myproject
source myproject/bin/activate

VS Code Setup

Install the Python extension from Microsoft for the best development experience.

Sources

For Linux installation, see our Linux Python guide. Windows users should check our Windows Python installation.