pip freeze
Packages and runtimes
Usage
python -m pip freeze > requirements.txtPrints every installed package with its exact version, ready to redirect into requirements.txt; it lists transitive dependencies as well as the ones you chose, so it has to be run inside the virtual environment.
Common flags
| Flag | Meaning |
|---|---|
| --local | skip packages inherited from a global site-packages |
| --exclude-editable | leave out -e installs, which are not installable lines |
| -r <file> | keep the order of an existing requirements file |
| --all | include pip, setuptools and wheel too |
Examples
python -m pip freeze > requirements.txtwrites exact versions of everything installed
python -m pip freeze --exclude-editablea list you can hand to pip install -r
python -m pip freeze --localonly what this environment installed itself
The question is always what goes where: inside this project, or on the whole machine.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does pip freeze do?
Prints every installed package with its exact version, ready to redirect into requirements.txt; it lists transitive dependencies as well as the ones you chose, so it has to be run inside the virtual environment.
Q. How do I type it?
python -m pip freeze > requirements.txt — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
4 are listed here; the full set is in man pip. This command sits under Packages and runtimes.
Related commands
man page: man pip-freeze