Python Installation and venv
On this page
Goal
Make every project reproducible: isolated interpreter, pinned dependencies, and predictable runtime behavior in local dev and CI.
Minimal Setup
# Create venv python -m venv .venv # Activate (Windows PowerShell) .venv\Scripts\Activate.ps1 # Activate (macOS/Linux) source .venv/bin/activate # Verify interpreter python -c "import sys; print(sys.executable)"
Dependency Baseline
# Upgrade packaging tools python -m pip install --upgrade pip setuptools wheel # Install pinned deps python -m pip install requests==2.32.3 # Freeze for reproducibility python -m pip freeze > requirements.txt
Operational Checklist
- Use one venv per repo and keep
.venv/in.gitignore. - Pin dependencies (or lock) so behavior is consistent in CI and prod.
- Document the required Python version (README or tooling config).
Failure Modes
- Global installs: packages end up in system Python and leak between projects.
- Mixed interpreters: venv created with one Python but executed with another.
- Unpinned deps: same code behaves differently across machines.