Pinning Your Dependencies
The cookbook runs on your laptop. A teammate clones it, installs "Django", gets a newer release than yours, and a page that works for you crashes for them. The code was identical; the packages were not. The cure is a plain text file that says exactly what the project runs on.
The rule
Share the list, not the folder:
requirements.txtrebuilds any environment.
A requirements file lists one package per line, usually with an exact version (== is called pinning):
asgiref==3.9.1
Django==5.2.6
sqlparse==0.5.3You can write it by hand, or capture what is installed in the active environment:
pip freeze > requirements.txtpip freeze prints every package in the environment with its exact version, including the dependencies Django pulled in. That is why a clean environment matters: freeze a messy one and the list fills with packages the project never uses.
On any other machine, rebuild it:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtThe -r flag means "read the requirements from this file". Commit requirements.txt to the repository; keep .venv/ in .gitignore.
Exact pins give repeatable installs. When you want to upgrade, do it on purpose: install the newer version, run the tests, then freeze again and commit the new list.
(Tools like Poetry and uv keep the same idea in a lock file. The file name changes; the principle does not.)