pip uninstall package AND unique dependencies

前端 未结 1 764
情深已故
情深已故 2021-01-22 01:39

How does one cleanly uninstall a pip installed package and all dependencies used by package only (i.e. not shared with other packages)?

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-22 02:39

    pip does not natively support removing unused dependencies. This is a related discussion thread by the pip developers.

    There are several options you can consider:

    1. There is a package pip-autoremove, but it is no longer maintained, so you cannot be sure if it works and should use it with caution.

    2. There is another package pipdeptree which shows you the dependency tree of installed packages. See the dependency tree yourself and decide what is safe to be deleted.

    3. What I do is to work on virtual environments and write a requirements.txt for each environment. When I want to remove a package, I take it away from requirements.txt, and just completely delete the virtual environment. Then I re-create the environment with pip install -r requirements.txt.

    0 讨论(0)
提交回复
热议问题