Phase 1 — Foundations · Lesson 1 · 20 XP
Toolchain: uv, virtual environments, project layout
Every Python project depends on third-party packages. Without isolation, project A needing httpx 0.27 and project B needing 0.28 will conflict the moment you install one on the shared system Python. A virtual environment gives each project its own private set of packages so they can never collide.
uv creates and manages that environment for you, and replaces pip + venv + pip-tools with three commands:
- uv init <name> — scaffold a new project with pyproject.toml
- uv add <package> — add a dependency and install it into .venv
- uv run <command> — run something inside the project’s environment, no manual activation
pyproject.toml declares what your project needs in loose terms (httpx>=0.28). uv.lock pins exact resolved versions for every dependency and sub-dependency. Commit both: the lockfile is what makes an install reproducible for a teammate, CI, or production a month from now.
brew install uv
uv init lesson-01 && cd lesson-01
uv add httpx
uv run lesson-01Exercise
Install uv, scaffold a project with `uv init`, add httpx as a dependency, and write a one-line program that GETs https://httpbin.org/get and prints the status code. Run it with `uv run`.
Check yourself
1. What problem does a virtual environment solve?
2. What is the difference between pyproject.toml and uv.lock, and why do we commit both?
Answer the check-yourself questions to unlock this