pip freeze: Pin the Environment Command Reference
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 or to diff against a lock.
Common flags / usage
- pip freeze -- print all installed packages as name==version
- --exclude-editable -- skip -e editable installs (not portable)
- -l, --local -- exclude globally installed packages in a venv
- > requirements.txt -- redirect the snapshot to a file
Example
shell
- run: pip install -r requirements.txt
# Assert the resolved set matches the committed lock:
- run: |
pip freeze --exclude-editable | sort > /tmp/frozen.txt
diff <(sort requirements.lock) /tmp/frozen.txtIn CI
pip freeze emits "-e <path>" for editable installs and local checkout URLs for VCS installs, which are not portable to other runners. Use --exclude-editable when generating a lock other machines will consume.
Key takeaways
- pip freeze prints installed packages as exact name==version pins.
- Use --exclude-editable to keep the output portable across runners.
- Diff a fresh freeze against a committed lock to catch dependency drift.
Related guides
pip list: Inspect Installed Packages Command ReferenceReference for pip list in CI: showing installed packages and versions, --outdated and --format=json for scrip…
pip install -r requirements.txt: Command ReferenceReference for pip install -r requirements.txt in CI: installing a whole dependency file, hashed installs, con…
pip-compile (pip-tools): Lock Command ReferenceReference for pip-compile from pip-tools in CI: compiling requirements.in into a fully pinned requirements.tx…