Is there a way to uninstall multiple packages with pip?

孤街浪徒 提交于 2019-12-20 09:47:30

问题


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.


回答1:


Your command should actually work if you add the -y | --yes flag to pip :-)

-y, --yes Don't ask for confirmation of uninstall deletions.

Possibly:

% pip freeze | grep pyobjc-framework | xargs pip uninstall -y




回答2:


Redirect the grep output to a new file and run.

 pip uninstall -r <file name>

works I think.

pip freeze | grep pyobjc > packages_to_remove.txt
sudo pip uninstall -y -r packages_to_remove.txt



回答3:


I always use this:

pip freeze | xargs pip uninstall -y



回答4:


greping pip freeze returned:

Usage:   
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

no such option: -e

So I did it with pip list instead:

$ 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


来源:https://stackoverflow.com/questions/9406123/is-there-a-way-to-uninstall-multiple-packages-with-pip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!