How to freeze packages installed only in the virtual environment?
Solution 1:
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
.
Solution 2:
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/.