How to Install Python on macOS – Ultimate Guide (2025 Updated)

Here's the ultimate guide to installing Python on macOS, covering multiple methods (official installer, Homebrew, pyenv, and more) with troubleshooting tips.

Alby Andersen

Python is one of the most powerful programming languages, mostly used in data science, machine learning, and big data analytics.


Method 1: Install Python via Official Installer

Step 1: Download Python

Step 2: Run the Installer

  1. Open the .pkg file and follow the prompts.
  2. Check “Add Python to PATH” during installation.

Step 3: Verify Installation

python3 --version   # Should return "Python 3.x.x"
pip3 --version      # Check if pip is installed

Method 2: Install Python via Homebrew

Step 1: Install Homebrew (if missing)

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

Step 2: Install Python

brew install python

Step 3: Verify

which python3   # Should show path like /usr/local/bin/python3

Method 3: Install Multiple Versions with pyenv

Step 1: Install pyenv

brew install pyenv

Step 2: Add to Shell Config

Add these lines to ~/.zshrc (or ~/.bashrc):

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

Step 3: Install Python Versions

pyenv install 3.12.0   # Install specific version
pyenv global 3.12.0    # Set default version

Method 4: Use Xcode Command Line Tools

Step 1: Install Xcode CLI Tools

xcode-select --install

Step 2: Verify Python

python3 --version   # macOS includes Python 3.9+ by default (may be outdated)

Check Preinstalled Python

Most Macs come with Python 2.7 (deprecated) and Python 3.x (minimal).

python --version    # Python 2.7.x (do not use)
python3 --version   # System Python 3.x (if present)

Troubleshooting Common Issues

1. python3 Command Not Found

  • Ensure Python 3 was installed correctly.
  • Update PATH in ~/.zshrc:
  export PATH="/usr/local/bin:$PATH"

2. Conflicts Between Python Versions

Use pyenv to manage versions or create virtual environments:

python3 -m venv myenv
source myenv/bin/activate

3. Homebrew Permissions Issues

Fix ownership:

sudo chown -R $(whoami) /usr/local/*

Which Method Should You Use?

MethodBest ForProsCons
OfficialBeginners, single Python versionSimple, GUI-basedManual updates
HomebrewDevelopers needing latest versionsEasy updates, integrates with CLIRequires Homebrew setup
pyenvMultiple Python versions/projectsVersion flexibilitySlightly complex setup
Xcode CLIMinimal setup (uses system Python)No additional installsOutdated Python version

  1. Use Homebrew or pyenv for development.
  2. Always create virtual environments (venv or pipenv) for projects.
  3. Avoid modifying the system Python (/usr/bin/python3).

Next Steps

  • Install an IDE like VS Code or PyCharm.
  • Learn to use pip for package management:
  pip3 install pandas numpy
Share This Article