Initial commit
This commit is contained in:
267
skills/django-setup/platform-install/windows.md
Normal file
267
skills/django-setup/platform-install/windows.md
Normal file
@@ -0,0 +1,267 @@
|
||||
# Python Installation - Windows
|
||||
|
||||
## Check Current Version
|
||||
|
||||
**PowerShell or Command Prompt:**
|
||||
```powershell
|
||||
python --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: Official Python Installer (Recommended)
|
||||
|
||||
**Why this method:**
|
||||
- Official releases from python.org
|
||||
- Includes pip automatically
|
||||
- Easy installation
|
||||
|
||||
**Steps:**
|
||||
1. Visit [python.org/downloads](https://www.python.org/downloads/)
|
||||
2. Click **"Download Python 3.13.x"** button
|
||||
3. Run the downloaded `.exe` installer
|
||||
|
||||
**⚠️ CRITICAL: Check "Add Python to PATH"**
|
||||
- This checkbox is at the bottom of the installer
|
||||
- **Must check this box** or Python won't work from command line
|
||||
|
||||
4. Click "Install Now"
|
||||
5. Wait for installation to complete
|
||||
6. Click "Close"
|
||||
|
||||
**Verify installation:**
|
||||
```powershell
|
||||
python --version
|
||||
pip --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Option 2: Microsoft Store (Windows 10/11)
|
||||
|
||||
**Why this method:**
|
||||
- Easiest installation
|
||||
- Automatic PATH configuration
|
||||
- Auto-updates through Microsoft Store
|
||||
|
||||
**Steps:**
|
||||
1. Open **Microsoft Store** app
|
||||
2. Search for "Python 3.13"
|
||||
3. Click **"Get"** or **"Install"**
|
||||
4. Wait for installation
|
||||
5. Restart terminal
|
||||
|
||||
**Verify:**
|
||||
```powershell
|
||||
python --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Option 3: Chocolatey Package Manager
|
||||
|
||||
**Why this method:**
|
||||
- Command-line package management (like Homebrew on macOS)
|
||||
- Good for automated setups
|
||||
- Easy updates: `choco upgrade python`
|
||||
|
||||
**Install Chocolatey first:**
|
||||
|
||||
Open **PowerShell as Administrator** and run:
|
||||
```powershell
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
||||
```
|
||||
|
||||
**Install Python:**
|
||||
```powershell
|
||||
choco install python --version=3.13.0
|
||||
```
|
||||
|
||||
**Verify:**
|
||||
```powershell
|
||||
python --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Option 4: Scoop Package Manager
|
||||
|
||||
**Why this method:**
|
||||
- Lightweight package manager
|
||||
- No admin rights required
|
||||
- Clean installations
|
||||
|
||||
**Install Scoop:**
|
||||
```powershell
|
||||
irm get.scoop.sh | iex
|
||||
```
|
||||
|
||||
**Install Python:**
|
||||
```powershell
|
||||
scoop install python
|
||||
```
|
||||
|
||||
**Verify:**
|
||||
```powershell
|
||||
python --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configure PATH (If Python Not Found)
|
||||
|
||||
### Check if Python is in PATH
|
||||
|
||||
**Open Command Prompt and run:**
|
||||
```cmd
|
||||
where python
|
||||
```
|
||||
|
||||
**If nothing appears, Python is not in PATH.**
|
||||
|
||||
### Add Python to PATH Manually
|
||||
|
||||
**Find Python installation location:**
|
||||
- Official installer: `C:\Users\<YourName>\AppData\Local\Programs\Python\Python313\`
|
||||
- Microsoft Store: `C:\Users\<YourName>\AppData\Local\Microsoft\WindowsApps\`
|
||||
|
||||
**Add to PATH:**
|
||||
1. Open **Start Menu**
|
||||
2. Search "Environment Variables"
|
||||
3. Click **"Edit the system environment variables"**
|
||||
4. Click **"Environment Variables"** button
|
||||
5. Under "User variables", select **"Path"**
|
||||
6. Click **"Edit"**
|
||||
7. Click **"New"**
|
||||
8. Add Python paths:
|
||||
- `C:\Users\<YourName>\AppData\Local\Programs\Python\Python313\`
|
||||
- `C:\Users\<YourName>\AppData\Local\Programs\Python\Python313\Scripts\`
|
||||
9. Click **"OK"** on all dialogs
|
||||
10. **Restart terminal/PowerShell**
|
||||
|
||||
**Verify:**
|
||||
```powershell
|
||||
python --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Issue: `python: command not found`
|
||||
|
||||
**Solution 1: Use `py` launcher instead**
|
||||
```powershell
|
||||
py --version
|
||||
py -m venv venv
|
||||
```
|
||||
|
||||
**Solution 2: Add to PATH** (see section above)
|
||||
|
||||
**Solution 3: Reinstall Python**
|
||||
- Uninstall current Python
|
||||
- Reinstall and **check "Add Python to PATH"**
|
||||
|
||||
### Issue: Multiple Python versions installed
|
||||
|
||||
**List all versions:**
|
||||
```powershell
|
||||
py --list
|
||||
```
|
||||
|
||||
**Use specific version:**
|
||||
```powershell
|
||||
py -3.13 --version
|
||||
py -3.13 -m venv venv
|
||||
```
|
||||
|
||||
### Issue: PowerShell Execution Policy Error
|
||||
|
||||
**When activating venv:**
|
||||
```
|
||||
venv\Scripts\Activate.ps1 : File cannot be loaded because running scripts is disabled
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
```powershell
|
||||
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||
```
|
||||
|
||||
**Then retry activation:**
|
||||
```powershell
|
||||
venv\Scripts\Activate.ps1
|
||||
```
|
||||
|
||||
### Issue: `pip` not found
|
||||
|
||||
**Use python -m pip instead:**
|
||||
```powershell
|
||||
python -m pip --version
|
||||
python -m pip install --upgrade pip
|
||||
```
|
||||
|
||||
### Issue: Long path errors
|
||||
|
||||
**Enable long paths in Windows:**
|
||||
|
||||
Open **PowerShell as Administrator**:
|
||||
```powershell
|
||||
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
|
||||
```
|
||||
|
||||
Restart computer.
|
||||
|
||||
---
|
||||
|
||||
## Using Windows Subsystem for Linux (WSL)
|
||||
|
||||
**Alternative: Use Linux Python on Windows**
|
||||
|
||||
**Install WSL:**
|
||||
```powershell
|
||||
wsl --install
|
||||
```
|
||||
|
||||
**Install Ubuntu:**
|
||||
```powershell
|
||||
wsl --install -d Ubuntu
|
||||
```
|
||||
|
||||
**Then follow:** [linux-ubuntu.md](linux-ubuntu.md) for Python installation
|
||||
|
||||
---
|
||||
|
||||
## Verification Checklist
|
||||
|
||||
- [ ] `python --version` shows 3.11+ (or `py --version`)
|
||||
- [ ] `pip --version` works (or `py -m pip --version`)
|
||||
- [ ] `python -m venv test_venv` creates test environment
|
||||
- [ ] Can activate test venv: `test_venv\Scripts\activate`
|
||||
- [ ] Prompt shows `(test_venv)` prefix
|
||||
|
||||
**Clean up test:**
|
||||
```powershell
|
||||
rmdir /s test_venv
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Development Tools (Optional)
|
||||
|
||||
**Install Windows Terminal** (better than Command Prompt):
|
||||
- Download from Microsoft Store
|
||||
- Or: https://aka.ms/terminal
|
||||
|
||||
**Install Git for Windows:**
|
||||
- Download from: https://git-scm.com/download/win
|
||||
|
||||
**Install VS Code:**
|
||||
- Download from: https://code.visualstudio.com/
|
||||
|
||||
---
|
||||
|
||||
[← Back to django-project-setup](../SKILL.md)
|
||||
Reference in New Issue
Block a user