How to freeze packages installed only in the virtual environment, that is, without the global ones?
8 Answers
You need to use the -l
or --local
option to freeze only the local packages (and not the global ones)
pip freeze -l > requirements.txt
Make sure you are working in the virtualenv
before doing pip freeze -l
.

- 9,824
- 5
- 32
- 52

- 2,056
- 1
- 16
- 8
-
1For me this worked (or use `python` for older versions): `python3 -m pip freeze -l > requirements.txt` – user2340939 May 19 '19 at 22:43
Only local packages on virtual environment
pip freeze -l > requirements.txt # or --local instead of -l
Only local packages installed by the user on virtual environment
pip freeze --user > requirements.txt
See the documentation for further details: https://pip.pypa.io/en/stable/reference/pip_freeze/.

- 15,395
- 32
- 113
- 196

- 119
- 1
- 4
I'm on Windows 10, python 3.6, with my virtual environment called env activated using command prompt I found that pip freeze -l
does not work (error), python -m pip freeze -l
does not work (gets global packages) but changing into my virtual environment Scripts directory and running pip freeze
or pip freeze -l
works. Here is an example of this solution/work-around with my virtual environment, env:
cd \env\Scripts
pip freeze > ..\..\requirements.txt

- 714
- 9
- 12
I did try everything, even i inside venv it not worked. This code worked for me. It shows only pip packages in venv.
venv\Scripts\python.exe venv\Scripts\pip.exe freeze > requirements.txt

- 29
- 4
Try the following command:
pip -E /path/to/env/ freeze

- 15,395
- 32
- 113
- 196

- 1,533
- 10
- 14
-
I think the `-E` parameter is use _inside_ the requirements.txt file to show a version control project address – saul.shanabrook Nov 10 '11 at 13:13
-
They are different "-E" params: this one is command line params that says pip to do inside the given virtualenv – Dima Bildin Nov 10 '11 at 16:16
-
Could you possible point me to documentation for this? Does it only freeze the specified virtuelenv even with global site packages enabled? – saul.shanabrook Nov 10 '11 at 21:30
-
-
1`$ pip -E venv/ freeze Usage: pip COMMAND [OPTIONS] pip: error: no such option: -E` – Mittenchops Apr 27 '13 at 23:09