【发布时间】:2012-03-13 10:47:15
【问题描述】:
我正在尝试删除所有已安装的以“pyobjc-framework”为前缀的软件包。我尝试了以下方法:
% pip freeze | grep pyobjc-framework | xargs pip uninstall
但这很糟糕,因为每个 pip 卸载都需要确认(也许一种绕过它的方法是一种解决方案)。
请在我不得不手动分解和卸载它们之前提供帮助!没有人想要那样。
【问题讨论】:
我正在尝试删除所有已安装的以“pyobjc-framework”为前缀的软件包。我尝试了以下方法:
% pip freeze | grep pyobjc-framework | xargs pip uninstall
但这很糟糕,因为每个 pip 卸载都需要确认(也许一种绕过它的方法是一种解决方案)。
请在我不得不手动分解和卸载它们之前提供帮助!没有人想要那样。
【问题讨论】:
将 grep 输出重定向到新文件并运行。
pip uninstall -r <file name>
我认为有效。
pip freeze | grep pyobjc > packages_to_remove.txt
sudo pip uninstall -y -r packages_to_remove.txt
【讨论】:
pip freeze | grep pyobjc > packages_to_remove.txt; sudo pip uninstall -y -r packages_to_remove.txt 应该这样做。注意,当同时使用 -r 标志和文件参数时,-y 标志必须放在第一位。呵呵。
如果您将-y | --yes 标志添加到 pip 中,您的命令应该可以正常工作 :-)
-y, --yes 不要求确认卸载删除。
可能:
% pip freeze | grep pyobjc-framework | xargs pip uninstall -y
【讨论】:
% pip freeze | grep pyobjc-framework | xargs -n 1 sudo pip uninstall -y 谢谢!
我总是用这个:
pip freeze | xargs pip uninstall -y
【讨论】:
greping pip freeze 返回:
Usage:
pip uninstall [options] <package> ...
pip uninstall [options] -r <requirements file> ...
no such option: -e
所以我改为使用pip list:
$ pip list | grep tempest | xargs pip uninstall -y
Uninstalling neutron-tempest-plugin-0.0.0:
Successfully uninstalled neutron-tempest-plugin-0.0.0
Uninstalling octavia-tempest-plugin-0.0.0:
Successfully uninstalled octavia-tempest-plugin-0.0.0
Uninstalling tempest-19.0.1.dev152:
Successfully uninstalled tempest-19.0.1.dev152
【讨论】:
只需将这些包准备为列表:
pip uninstall <list of requirement> -y
e.g.:
pip uninstall termcolor, imgviz, matplotlib, PyYAML, qtpy, Pillow, colorama, PyQt5, numpy -y
例如:用pip卸载依赖包,分三步:
1. pip show <package>
e.g.:
pip show labelme
...
Requires: termcolor, imgviz, matplotlib, PyYAML, qtpy, Pillow, colorama, PyQt5, numpy
...
2. pip uninstall <package>
e.g.
pip uninstall labelme
3. pip uninstall <list of requirement> -y
e.g.:
pip uninstall termcolor, imgviz, matplotlib, PyYAML, qtpy, Pillow, colorama, PyQt5, numpy -y
【讨论】:
最简单的方法。使用删除所有torch 相关包,例如:
pip uninstall `pip freeze | grep torch`
【讨论】: