45

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.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
wh1tney
  • 1,157
  • 1
  • 9
  • 16

7 Answers7

77

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

jdi
  • 90,542
  • 19
  • 167
  • 203
  • Bingo. -y is the flag I needed. I also need xargs to pass a single argument at a time so my final command looks like this: `% pip freeze | grep pyobjc-framework | xargs -n 1 sudo pip uninstall -y` Thanks! – wh1tney Feb 23 '12 at 03:20
15

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
Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Matt Alcock
  • 12,399
  • 14
  • 45
  • 61
  • 1
    er, sorry. `pip freeze | grep pyobjc > packages_to_remove.txt; sudo pip uninstall -y -r packages_to_remove.txt` should do it. Note, the -y flag must come first when also using the -r flag and a file argument. Doh. – wh1tney Feb 23 '12 at 03:49
10

I always use this:

pip freeze | xargs pip uninstall -y
josephmisiti
  • 9,862
  • 11
  • 56
  • 72
6

Easiest way. use remove all torch related packages for example:

pip uninstall `pip freeze | grep torch`
MD Mushfirat Mohaimin
  • 1,966
  • 3
  • 10
  • 22
user8850287
  • 61
  • 1
  • 2
2

Just prepare those packages as list:

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 

For example: Uninstall package with its dependence with pip in three steps:

  1. show dependence list
  2. remove the package
  3. remove list of its dependence (copy it from 1.)

For detail:

 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
Jaja
  • 662
  • 7
  • 15
1

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
Noam Manos
  • 15,216
  • 3
  • 86
  • 85
1

Do pip uninstall -y -r <(pip freeze)

Chuma Umenze
  • 933
  • 12
  • 18