Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Python 3.12+ is the version every new project should target — it's faster (perf project), it has structural pattern matching from 3.10, exception groups from 3.11, and per-interpreter GIL changes from 3.12. The wrong instinct is to use whatever python3 is on your Mac (often a stale 3.9). The right instinct: install a version manager (uv or pyenv), pin per-project, and treat 'system Python' as untouchable. uv (from Astral, the ruff team) is the 2026 winner — it bundles version mgmt, virtualenvs, dep resolution, and pip into one ~25 MB binary that's 10–100× faster than pip.
uv is a next-generation Python package manager written in Rust that replaces pip, pip-tools, and virtualenv in a single binary. It resolves and installs dependencies 10-100× faster than pip and produces a lockfile (uv.lock) that pins the exact version of every package in the transitive graph. Pinning a Python version with uv python pin 3.12 ensures that every developer and CI run uses the same interpreter, eliminating 'works on my machine' failures caused by minor version differences.
uv --version to confirm.uv python install 3.12 and pin it in a fresh dir with echo "3.12" > .python-version.uv run python -c "import sys; print(sys.version)" and confirm you got 3.12.which python vs uv run which python. Note that uv keeps a project-scoped Python separate from your shell's.Use these three in order. Each builds on the one before.
In one paragraph, explain why I shouldn't use the `python3` that ships with macOS or Ubuntu — and what 'pin Python per project' actually means.
Walk me through what `uv python install 3.12` does: where the interpreter is downloaded from, where it's stored, how `uv run` finds it.
Compare uv, pyenv, conda, and Docker for Python version management. Pick a winning strategy for a 5-person team shipping a FastAPI service in 2026 and defend it.
# install uv (mac/linux):
$ curl -LsSf https://astral.sh/uv/install.sh | sh
# install Python 3.12 (uv manages versions like rustup):
$ uv python install 3.12
$ uv python list
cpython-3.12.2-macos-aarch64
cpython-3.11.8-macos-aarch64
...
# pin a project to a specific version:
$ echo "3.12" > .python-version
$ uv run python --version
Python 3.12.2
# alternative: pyenv (older but fine):
$ brew install pyenv
$ pyenv install 3.12.2
$ pyenv local 3.12.2python3 main.py