How to freeze packages installed only in the virtual environment?
For me (macOS) the following worked
path/to/venv/bin/pip3 freeze -l
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
.
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/.