My approach is the following:
- I my
.bashrc
I create the following alias: alias pipfreezeignore='pip freeze | grep -vFxf ignore_requirements.txt'
- Create the virtual environment, and install first all the packages that I do not want to keep track of (i.e.
pip install jedi flake8 importmagic autopep8 yapf
).
- Immediately save them in a
ignore_requirements.txt
file, as in pip freeze > ignore_requirements.txt
.
- Install the rest of packages (e.g.
pip install django
)
- Use
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…