Skip to content

Appendix

Environment setup

The course assumes Python 3.12 or newer and uv for dependency management.

curl -LsSf https://astral.sh/uv/install.sh | sh
uv python install 3.13
uv init my-project && cd my-project
uv add requests
uv run python -c "import requests; print(requests.__version__)"
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
uv python install 3.13
uv init my-project; cd my-project
uv add requests
uv run python -c "import requests; print(requests.__version__)"

Why uv rather than pip and venv

uv resolves and installs dependencies dramatically faster, manages Python versions itself, and produces a lockfile by default. The concepts are identical to pip and venv — if you learn uv, you can read a pip workflow without difficulty.

Quick reference

Running things

Task Command
Run a script uv run python script.py
Add a dependency uv add pandas
Add a dev dependency uv add --dev pytest
Run tests uv run pytest
Lint uv run ruff check .
Format uv run ruff format .
Type check uv run mypy .
Serve these docs mkdocs serve

Git, day to day

Task Command
New branch git switch -c feature/thing
Stage and commit git add -p && git commit
Push and set upstream git push -u origin HEAD
Update from main git fetch origin && git rebase origin/main
Undo last commit, keep changes git reset --soft HEAD~1
See what changed git diff / git diff --staged

Troubleshooting

command not found: python

On macOS and Linux the binary is often python3. Better: let uv manage it and use uv run python, which always resolves to the version pinned for the project.

ModuleNotFoundError for something I definitely installed

Almost always the wrong environment. You installed into one interpreter and are running another. uv run removes this class of problem entirely by always using the project's environment. To confirm which interpreter is active: uv run python -c "import sys; print(sys.executable)".

UnicodeDecodeError when reading a file

The file is not UTF-8. Pass the correct encoding explicitly — open(path, encoding="latin-1") — rather than stripping the offending bytes. Volume 1 covers why this happens.

My code works in the terminal but not in the editor

The editor is using a different interpreter. Point it at the project environment: in VS Code, Python: Select Interpreter and choose the one inside .venv.