Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
in /usr or usr/local ? did you install packages by hand or by apt/synaptic/software centre? – zeitue Jun 26 '12 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 '12 at 19:10
up vote 1 down vote accepted

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:


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

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 {

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.

share|improve this answer
Thanks, I know it's a disaster. – Rich Jun 28 '12 at 18:51

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.