有没有办法用pip卸载多个包?
我正在尝试删除所有已安装的“pyobjc-framework”前缀包。我已经尝试了以下操作:
% pip freeze | grep pyobjc-framework | xargs pip uninstall
但是这个 barfs 因为每个 pip 卸载都需要确认(也许绕过这个的方法是一个解决方案)。
请在我必须手动分解并卸载其中每个之前提供帮助!没有人想要这样。
I am attempting to remove all of the installed "pyobjc-framework"-prefixed packages. I have tried the following:
% pip freeze | grep pyobjc-framework | xargs pip uninstall
but this barfs because each pip uninstall requires confirmation (perhaps a way to bypass this would be a solution).
Please help before I have to break down and uninstall each of these manually! Nobody wants that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
如果您添加
-y | 您的命令实际上应该有效。 --yes
标记为 pip :-)可能:
% pip freeze | grep pyobjc 框架 | xargs pip uninstall -y
Your command should actually work if you add the
-y | --yes
flag to pip :-)Possibly:
% pip freeze | grep pyobjc-framework | xargs pip uninstall -y
将 grep 输出重定向到新文件并运行。
我认为有效。
Redirect the grep output to a new file and run.
works I think.
我总是用这个:
I always use this:
最简单的方法。使用删除所有与 torch 相关的包,例如:
Easiest way. use remove all
torch
related packages for example:只需将这些包准备为列表即可:
例如:使用 pip 分三步卸载包及其依赖项:
详细信息:
Just prepare those packages as list:
For example: Uninstall package with its dependence with pip in three steps:
For detail:
greping
pip freeze
返回:所以我用
pip list
代替:greping
pip freeze
returned:So I did it with
pip list
instead:执行
pip uninstall -y -r <(pip freeze)
Do
pip uninstall -y -r <(pip freeze)
您可以结合使用
pip freeze
、grep
和awk
命令来卸载以某些字符开头的软件包。以下是卸载以
PyQt
开头的软件包的示例:这将删除以
PyQt
开头的每个软件包。如果您想立即卸载所有软件包,可以执行以下操作:
这将从 pip 中删除每个软件包。
You can uninstall packages that start with certain characters using a combination of
pip freeze
,grep
, andawk
commands.Here's an example for uninstalling packages that start with
PyQt
:This will remove every package that starts with
PyQt
.If you want to uninstall all packages at once, you can do so with the following:
This will remove every package from pip.
pip freeze
输出的一个问题是它不能很好地解析使用--editable
/-e
安装的软件包标志,因为“-e”标志(如果在 git 存储库中,则可能后跟源 git URL)将出现在冻结列表中而不是包名称,例如:在这种情况下,而不是尝试提取包名称,使用 pip 更简单、更可靠list 而不是
pip freeze
,因为这将输出包名称,而不是它们的源:或者如果您更喜欢
cut
:A problem with the
pip freeze
output is that it doesn't parse so well with packages that were installed with the--editable
/-e
flag, because the "-e" flag (perhaps followed by source git URL if in a git repository) will appear in the freeze list instead of the package name, such as:In this case, rather than trying to extract the package name, it's simpler and more reliable to use
pip list
instead ofpip freeze
, as this will output the package names, not their source:Or if you prefer
cut
: