pip卸载程序包和唯一依赖项 [英] pip uninstall package AND unique dependencies

查看:714
本文介绍了pip卸载程序包和唯一依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何干净地卸载pip安装的软件包以及该软件包仅使用的所有依赖项(即不与其他软件包共享)?

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

推荐答案

pip本机不支持删除未使用的依赖项. 是由点子开发人员.

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. 有一个软件包 pip-autoremove ,但不再维护,因此您无法确定它是否有效,应谨慎使用.

  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.

还有另一个软件包 pipdeptree ,其中显示了已安装软件包的依赖关系树.亲自查看依赖关系树,并确定可以安全删除的内容.

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.

我要做的是在虚拟环境上工作,并为每个环境编写一个requirements.txt.当我想删除一个程序包时,我将其从requirements.txt拿走了,只是完全删除了虚拟环境.然后,用pip install -r requirements.txt重新创建环境.

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.

这篇关于pip卸载程序包和唯一依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆