How can I use a pip requirements file to uninstall as well as install packages?

前端 未结 10 1192
猫巷女王i
猫巷女王i 2021-01-30 04:48

I have a pip requirements file that changes during development.

Can pip be made to uninstall packages that do not appear in the requirement

10条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 05:17

    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.)

提交回复
热议问题