Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

2 Answers 2

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:

#!/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.

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

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
add comment

Your Answer

 
discard

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.