Install Python on macOS
Introduction
This chapter shows you how to install Python on macOS in a clean and reliable way for real projects. You will learn which installation method to choose, how to verify your environment, and how to avoid common PATH and version conflicts. Getting this setup right early saves you from many debugging issues later.
Prerequisites
- A Mac running a recent macOS version (Ventura, Sonoma, or newer recommended)
- Basic terminal knowledge (
cd,ls, running commands) - Internet access to download installers or Homebrew packages
- A code editor (recommended: VS Code)
Choose an Installation Method
On macOS, the two most practical choices are the official installer from python.org and Homebrew. For most developers, Homebrew is easier to maintain and upgrade over time.
Recommended strategy:
- Use Homebrew for long-term development workflow
- Use the official installer if your team standard requires it
- Avoid relying on the system Python for project work
Warning
Do not build your project environment on top of the macOS system Python. It may change between OS updates and break tooling unexpectedly.
Install Python with Homebrew (Recommended)
If Homebrew is not installed, install it first from brew.sh. Then install Python:
# Update Homebrew package metadata
brew update
# Install Python 3
brew install python
# Check Python version
python3 --version
# Check pip version
pip3 --versionTip
Best Practice
Use python3 and pip3 explicitly on macOS to avoid confusion with older python command mappings.
Install Python from python.org (Alternative)
If you prefer the official installer:
- Download the latest Python 3 macOS installer from python.org
- Run the
.pkginstaller - Complete setup with default options unless your team has custom requirements
- Open a new terminal window and verify installation
# Verify Python version
python3 --version
# Verify pip version
pip3 --versionFAQ
Should I use python or python3 on macOS?
Use python3 for clarity and consistency. On some systems, python may still map to older or unexpected interpreters.
Is Homebrew better than the official installer?
For many developers, yes. Homebrew usually makes upgrades and maintenance easier. The official installer is still a valid choice if your team standard requires it.
Why is virtual environment setup mandatory for projects?
It isolates dependencies per project, prevents version conflicts, and keeps local environments closer to CI and production behavior.
How do I check which Python my shell is using?
Run which python3 and python3 --version. These two commands tell you both path and version.