I have a pip requirements file that changes during development.
Can pip
be made to uninstall packages that do not appear in the requirement
While this doesn't directly answer the question, a better alternative to requirements.txt
now is using a Pipfile. This functions similarly to a Ruby Gemfile
. Currently, you need to make use of the pipenv tool but hopefully this will eventually be incorporated into pip
. This provides the pipenv clean
command which does what you want.
(Note that you can import an existing requirements.txt
with pipenv install -r requirements.txt
. After this you should have a Pipfile
and the requirements.txt
can be removed.)