To install Python on macOS, follow these steps:
Step 1: Check if Python is already installed
Open Terminal and run:
python3 --version
macOS comes with Python 2.x preinstalled (deprecated), but you want Python 3.x.
Step 2: Install Python 3 (Recommended via Homebrew)
1. Install Homebrew (if not installed)
Run this in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Verify installation:
brew --version
2. Install Python 3
brew install python
This installs the latest Python 3 version and pip3
.
Verify installation:
python3 --version
pip3 --version
Step 3: Optional – Set Up a Virtual Environment
Navigate to your project folder and run:
python3 -m venv env
source env/bin/activate
To deactivate:
deactivate
Step 4: Test Python
Run Python interactive shell:
python3
You should see something like:
Python 3.x.x (default, ...)
>>>
Troubleshooting