0

I messed up some core packages in my Python distribution, probably through some failed easy_install commands. Is there any way in Ubuntu to blow away the site's Python installation and re-install it to the form defined in the Ubuntu package manager?

I am running Ubuntu 10.04.

2
  • in /usr or usr/local ? did you install packages by hand or by apt/synaptic/software centre?
    – zeitue
    Jun 26, 2012 at 5:30
  • It's in /usr/lib/python2.6/.... Some are installed by synaptic, but the others are installed using pip and easy_install. I'm fine blowing those away if I can get at however the default synaptic state is in.
    – Rich
    Jun 26, 2012 at 19:10

2 Answers 2

1

For future reference I recommend installing virtualenv and virtualenvwrapper to stop anything like this happening again. Virtaulenv lets you keep separate, distinct python installations for each of your projects and Virtualenvwrapper makes it easy to work with them. Then any mess ups you cause are limited to one project.

For your current problem, anything you installed using pip can be removed with pip's uninstall command. The following shell script from pastebin (I haven't tested it, just to give you warning, and do not accept any responsibility for any loss or damage it might cause , though I can't see anything harmful in it) should remove all pip packages simultaneously:

#!/bin/bash

#if [ "$#" -ne 1 ]; then
#    echo "Usage: $0 <py pkg name using \$(pip freeze -l)>"
#    exit
#fi

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

Regrettably I don't think there is an easy way to remove packages installed with easy-install because it doesn't keep track of what you installed, which is partly why pip was developed.

0
0

The stuff you installed with easy_install should have all ended up in /usr/local/lib/python2.7/dist-packages/. So you can just delete everything in there. Nothing was installed from a package will be in there, so it's safe to delete.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .