How does one cleanly uninstall a pip installed package and all dependencies used by package only (i.e. not shared with other packages)?
1 Answer
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:
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.
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.
What I do is to work on virtual environments and write a
requirements.txtfor each environment. When I want to remove a package, I take it away fromrequirements.txt, and just completely delete the virtual environment. Then I re-create the environment withpip install -r requirements.txt.
3 Comments
pipdeptree looks the most interesting of the three choices. I will investigate further. Thank you.pip freeze in case a project breaks after updating a virtualenv