5

Over the course of the year I've become more familiar with programming on OS X, and I think in my initial excitement I installed a whole bunch of things that I won't use and that pollute my development environment.

In particular, I find that with pip, brew, port, and easy_install, I've added all sorts of packages for all sorts of versions, and even for different systems (Snow Leopard and Mountain Lion).

So now, I was wondering if there was any way for me to start from scratch? I'd prefer to keep my files and programs, so no reinstalling the OS. If there is an easy way to mass uninstall packages for each of the four, that would help tremendously.

Thanks!

Johnny W
  • 185
  • 1
  • 2
  • 7

3 Answers3

4

pip and easy_install install the mostly the same thing (both are tools that install most of the same packages).

First get a list of all installed packages, as you might want to keep some:

$ pip freeze > packages.txt

This should be a fairly large file that lists most (if not all) packages that you have installed in your default system python.

Edit that file and delete those packages that you want to keep, so it contains only those you want to get rid of (and no other lines or comments), then adjust the following script:

#!/bin/bash

for plugin in $(cat packages.txt); do
    PLUGIN=$(echo "$plugin" | awk -F == '{print }')
    echo "Uninstalling $PLUGIN..."
    expect -c "spawn pip uninstall $PLUGIN
    expect {
        \"Proceed (y/n)?\" {
            send \"y\r\n\"
            expect {
                exit
            }
        }
    }"    
done

For macports, see the uninstalling guide and associated warnings.

For brew, see this superuser question

Coincidentally, that should tell you that such questions belong at superuser.com, and not on stackoverflow - which is for programming related queries.

Don't worry - someone will eventually move your thread there.

Community
  • 1
  • 1
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
0

On Linux I use:

$ pip freeze > args | pip uninstall -y -r args | rm args

On Windows I use:

$ pip freeze > args | pip uninstall -y -r args | del args

-y flag autoconfirm deletion, so it will not prompt you for if you would like to delete that package -r tells to use requirements file, the name of the file in my example is args which was created by pip freeze > args

Vlad Bezden
  • 83,883
  • 25
  • 248
  • 179
0

On MacOS you can use:

brew list | xargs brew uninstall