问题
How to freeze packages installed only in the virtual environment, that is, without the global ones?
回答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
.
回答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/.
回答3:
Install whatever you need to freeze in your virtual environment, and then
pip freeze > requirements.txt
After that install the packages in the virtual environment that you do not want to freeze.
回答4:
Try the following command:
pip -E /path/to/env/ freeze
来源:https://stackoverflow.com/questions/8073097/how-to-freeze-packages-installed-only-in-the-virtual-environment