Initial commit
This commit is contained in:
184
skills/django-setup/platform-install/macos.md
Normal file
184
skills/django-setup/platform-install/macos.md
Normal file
@@ -0,0 +1,184 @@
|
||||
# Python Installation - macOS
|
||||
|
||||
## Check Current Version
|
||||
|
||||
```bash
|
||||
python3 --version
|
||||
```
|
||||
|
||||
If you see Python 3.11+, you're good to go! [← Back to main skill](../SKILL.md#step-2-create-virtual-environment)
|
||||
|
||||
---
|
||||
|
||||
## 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):**
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
|
||||
**Install Python 3.13:**
|
||||
```bash
|
||||
brew install python@3.13
|
||||
```
|
||||
|
||||
**Verify installation:**
|
||||
```bash
|
||||
python3.13 --version
|
||||
# Or if it's the default:
|
||||
python3 --version
|
||||
```
|
||||
|
||||
**Add to PATH (if needed):**
|
||||
```bash
|
||||
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:**
|
||||
1. Visit [python.org/downloads](https://www.python.org/downloads/)
|
||||
2. Click "Download Python 3.13.x" button
|
||||
3. Open downloaded `.pkg` file
|
||||
4. Follow installation wizard
|
||||
5. Restart Terminal
|
||||
|
||||
**Verify:**
|
||||
```bash
|
||||
python3 --version
|
||||
```
|
||||
|
||||
**Add to PATH (if needed):**
|
||||
```bash
|
||||
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:**
|
||||
```bash
|
||||
brew install pyenv
|
||||
```
|
||||
|
||||
**Install Python 3.13:**
|
||||
```bash
|
||||
pyenv install 3.13.0
|
||||
```
|
||||
|
||||
**Set as global default:**
|
||||
```bash
|
||||
pyenv global 3.13.0
|
||||
```
|
||||
|
||||
**Or set for specific project:**
|
||||
```bash
|
||||
cd /path/to/project
|
||||
pyenv local 3.13.0
|
||||
```
|
||||
|
||||
**Configure shell (add to ~/.zshrc):**
|
||||
```bash
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
eval "$(pyenv init --path)"
|
||||
eval "$(pyenv init -)"
|
||||
```
|
||||
|
||||
**Reload shell:**
|
||||
```bash
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
**Verify:**
|
||||
```bash
|
||||
python --version # Should show 3.13.0
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Issue: `command not found: python3`
|
||||
|
||||
**After Homebrew install:**
|
||||
```bash
|
||||
brew link python@3.13
|
||||
```
|
||||
|
||||
**Check where Python is:**
|
||||
```bash
|
||||
which python3
|
||||
brew --prefix python@3.13
|
||||
```
|
||||
|
||||
### Issue: Multiple Python versions conflict
|
||||
|
||||
**List all Python installations:**
|
||||
```bash
|
||||
which -a python3
|
||||
ls -l /usr/local/bin/python*
|
||||
```
|
||||
|
||||
**Use specific version:**
|
||||
```bash
|
||||
python3.13 -m venv venv # Force Python 3.13
|
||||
```
|
||||
|
||||
### Issue: SSL certificate errors
|
||||
|
||||
**Install certificates:**
|
||||
```bash
|
||||
/Applications/Python\ 3.13/Install\ Certificates.command
|
||||
```
|
||||
|
||||
Or via Homebrew:
|
||||
```bash
|
||||
brew install openssl
|
||||
```
|
||||
|
||||
### Issue: Xcode Command Line Tools needed
|
||||
|
||||
**Install:**
|
||||
```bash
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verification Checklist
|
||||
|
||||
- [ ] `python3 --version` shows 3.11+
|
||||
- [ ] `which python3` shows installation path
|
||||
- [ ] `python3 -m pip --version` works
|
||||
- [ ] `python3 -m venv test_venv` creates test environment
|
||||
- [ ] Can activate test venv: `source test_venv/bin/activate`
|
||||
|
||||
**Clean up test:**
|
||||
```bash
|
||||
rm -rf test_venv
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
[← Back to django-project-setup](../SKILL.md)
|
||||
Reference in New Issue
Block a user