我正在尝试删除所有已安装的带有“pyobjc-framework”前缀的软件包。我尝试过以下方法:
% pip freeze | grep pyobjc-framework | xargs pip uninstall
但是这个 barfs 因为每个 pip 卸载都需要确认(也许绕过这个的方法是一个解决方案)。
请在我必须手动分解和卸载它们之前提供帮助!没有人想要这样。
如果您将
-y | --yes
标志添加到 pip 中,您的命令实际上应该有效:-)
-y, --yes 不要求确认卸载删除。
可能:
% pip freeze | grep pyobjc-framework | xargs pip uninstall -y
将 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 | xargs pip uninstall -y
最简单的方法。使用删除所有
torch
相关软件包,例如:
pip uninstall `pip freeze | grep torch`
只需按照清单准备这些包裹即可:
pip uninstall <list of requirement> -y
e.g.:
pip uninstall termcolor, imgviz, matplotlib, PyYAML, qtpy, Pillow, colorama, PyQt5, numpy -y
(Some version of pip require to remove commas, s. below)
pip uninstall termcolor imgviz matplotlib -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
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 -y -r <(pip freeze)
您可以使用
pip freeze
、grep
和 awk
命令的组合来卸载以某些字符开头的软件包。
以下是卸载以 PyQt
开头的软件包的示例:
pip freeze | grep -E '^PyQt'
pip freeze | grep -E '^PyQt' | awk -F'==' '{print $1}' | xargs pip uninstall -y
这将删除所有以
PyQt
开头的包。