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

前端 未结 10 1191
猫巷女王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:30

    It's not a feature of pip, no. If you really want such a thing, you could write a script to compare the output of pip freeze with your requirements.txt, but it would likely be more hassle than it's worth.

    Using virtualenv, it is easier and more reliable to just create a clean environment and (re)install from requirements.txt, like:

    deactivate
    rm -rf venv/
    virtualenv venv/
    source venv/bin/activate
    pip install -r requirements.txt
    

提交回复
热议问题