3.2 KiB
3.2 KiB
Python Installation - macOS
Check Current Version
python3 --version
If you see Python 3.11+, you're good to go! ← Back to main skill
Installation Methods
Option 1: Homebrew (Recommended)
Why Homebrew:
- Easy updates:
brew upgrade python@3.13 - Manages dependencies automatically
- Industry standard on macOS
Install Homebrew (if not installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Python 3.13:
brew install python@3.13
Verify installation:
python3.13 --version
# Or if it's the default:
python3 --version
Add to PATH (if needed):
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc # For M1/M2 Macs
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc # For Intel Macs
source ~/.zshrc
Option 2: Official Python Installer
When to use: You want specific Python version or don't use Homebrew
Steps:
- Visit python.org/downloads
- Click "Download Python 3.13.x" button
- Open downloaded
.pkgfile - Follow installation wizard
- Restart Terminal
Verify:
python3 --version
Add to PATH (if needed):
echo 'export PATH="/Library/Frameworks/Python.framework/Versions/3.13/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Option 3: pyenv (Multiple Python Versions)
Why pyenv:
- Manage multiple Python versions side-by-side
- Easy switching between projects
- Preferred by professional developers
Install pyenv:
brew install pyenv
Install Python 3.13:
pyenv install 3.13.0
Set as global default:
pyenv global 3.13.0
Or set for specific project:
cd /path/to/project
pyenv local 3.13.0
Configure shell (add to ~/.zshrc):
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
Reload shell:
source ~/.zshrc
Verify:
python --version # Should show 3.13.0
Troubleshooting
Issue: command not found: python3
After Homebrew install:
brew link python@3.13
Check where Python is:
which python3
brew --prefix python@3.13
Issue: Multiple Python versions conflict
List all Python installations:
which -a python3
ls -l /usr/local/bin/python*
Use specific version:
python3.13 -m venv venv # Force Python 3.13
Issue: SSL certificate errors
Install certificates:
/Applications/Python\ 3.13/Install\ Certificates.command
Or via Homebrew:
brew install openssl
Issue: Xcode Command Line Tools needed
Install:
xcode-select --install
Verification Checklist
python3 --versionshows 3.11+which python3shows installation pathpython3 -m pip --versionworkspython3 -m venv test_venvcreates test environment- Can activate test venv:
source test_venv/bin/activate
Clean up test:
rm -rf test_venv