Wednesday, May 1, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 898  / 3 Years ago, sun, september 19, 2021, 7:44:20

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.


More From » package-management

 Answers
2

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
"
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.


[#37278] Monday, September 20, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
adedes

Total Points: 454
Total Questions: 114
Total Answers: 111

Location: Turks and Caicos Islands
Member since Fri, May 8, 2020
4 Years ago
;