pip freeze: Pin Your Environment for CI
Snapshot the exact versions installed right now.
pip freeze outputs installed packages in requirements format with exact versions. Redirect it to a file to capture a reproducible dependency set.
What it does
Prints every installed package as name==version. Editable installs appear as "-e" lines and VCS installs as their source URLs, which matters when you reuse the output.
Common usage
Terminal
pip freeze
pip freeze > requirements.txt
pip freeze --exclude-editable > requirements.txtCommon CI gotcha: editable lines
pip freeze emits "-e <path>" for editable installs and the local checkout for VCS installs, which are not portable to another machine. Exclude them when generating a lock for other runners.
Terminal
# Non-portable line in output:
# -e git+https://...#egg=mypkg
# Fix:
pip freeze --exclude-editable > requirements.txtOptions
| Option | Does |
|---|---|
| --exclude-editable | Skip editable installs |
| -l, --local | Exclude globally-installed packages |
| -r, --requirement FILE | Order output to match a file |
Related guides
pip install -r: Install from requirements.txt in CIHow pip install -r installs every dependency from a requirements file, the flags that make it reproducible in…
pip list: Inspect Installed PackagesHow pip list shows installed packages and versions, the --outdated and --format flags useful in CI, and how t…
uv pip compile: Generate a Pinned requirements.txtHow uv pip compile turns requirements.in into a fully pinned requirements.txt, the --generate-hashes flag, an…