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 pythonThis 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 pyenvConfigure 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.0Using Official Installer
You can also download the official installer from python.org:
- Visit python.org/downloads/
- Download the latest macOS installer
- Double-click the .pkg file
- Follow the installation prompts
Verify Installation
python3 --version
pip3 --versionVirtual Environment Setup
python3 -m venv myproject
source myproject/bin/activateVS 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.