Title basically says it all. How can I tell pip freeze
to ignore certain packages, like pylint
and pep8
, and their dependencies?
pip freeze might seem very useful initially but it can mess up your project because of the following reasons: It dumps all the libraries installed in your project including dependencies and sub-dependencies in the requirements.
The recommended approach is to use a requirements. txt file (readthedocs.org) that contains a list of commands for pip that installs the required versions of dependent packages. The most common command is pip freeze > requirements. txt , which records an environment's current package list into requirements.
You just need to delete the venv folder and initialize new one.
pip freeze , like conda list --export , is more for generating requirements files for your environment. For example, if you have created a package in your customized environment with certain dependencies, you can do conda list --export > requirements.
My approach is the following:
.bashrc
I create the following alias: alias pipfreezeignore='pip freeze | grep -vFxf ignore_requirements.txt'
pip install jedi flake8 importmagic autopep8 yapf
).ignore_requirements.txt
file, as in pip freeze > ignore_requirements.txt
.pip install django
)pipfreezeignore > requirements.txt
(in the same folder where ignore_requirements.txt
is) so I just get in requirements.txt
the installed packages that are not in ignore_requirements.txt
If you always want to ignore the same packages (through all your virtual environments), you might redefine the alias as in alias pipfreezeignore='pip freeze | grep -vFxf /abs/path/to/ignore_requirements.txt'
Just make sure that no packages from ignore_requirements.txt
are not actually necessary for your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With