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 wanted to remove and reinstall python2.7 interpreter on 12.04

But when I did sudo apt-get remove python2.7, The crazy terminal started to remove everything!!! Any idea how I can restore whatever I've removed?

share|improve this question
    
now my unity UI is no longer working, ? icons starts to populate the UI... –  alvas Sep 13 '12 at 6:07
    
now nothing is working, i have to work on windows... –  alvas Sep 13 '12 at 6:23
    
Can you boot to the Ubuntu even in the console? –  Anwar Shah Sep 13 '12 at 6:30
    
recovery console works but even apt-get goes crazy with errors... –  alvas Sep 13 '12 at 6:40
    
Actually, core tools do not have much dependencies beside C libs. Both apt/aptitude does not depends on python. apt just suggests python. Honestly, I was in doubt about that so I tried U12.04 in VBox, uninstalled python2.7 as you did, reboot, unable to login, switch to tty6, I was able reinstall gedit (dep on python) using apt-get, even aptitude is working well. apt-get install ubuntu-desktop should solve such case. Probably, apt got into unclean state after uninstalling python2.7 was interrupted. Could you post the output/errors you got when running sudo apt-get install python2.7 –  Sneetsher Oct 4 at 15:17

9 Answers 9

up vote 11 down vote accepted
+50

While reinstalling Ubuntu is probably the easiest way, it's worth pointing out that it's possible to recover without reinstalling everything.

To do this, manually download the python2.7 package (and its dependencies), and manually install them using dpkg (bypassing APT, which requires Python). Once that's installed, apt should work again, and so apt-get install ubuntu-desktop will restore your system. (If apt-get still doesn't work, you might also need to download and install any missing dependencies.)

In the future, if you need to reinstall a package, instead use

sudo apt-get install --reinstall python2.7

or

sudo aptitude reinstall python2.7

which reinstalls the package without having to remove the dependencies.

share|improve this answer
3  
BTW, aptitude is gone after removing python. =) –  alvas Oct 14 '12 at 11:42

Removing Python is not a good idea as much of Ubuntu depends on it. You may have seen a warning telling you which packages depend on python and thus will be removed with Python. When proceeding you end up with a quite stripped down OS.

Reinstalling Ubuntu would now be the easiest and safest way to get it back. Take care not to delete your HOME when you do so.

share|improve this answer
3  
I am not sure, but I think, he can restore the PC if he have still access to TTY. sudo apt-get install ubuntu-desktop should do the job –  Anwar Shah Sep 13 '12 at 6:36
    
any idea how i could reinstall on the root console? that's the only thing accessible now from my ubuntu, how could i reinstall using wubi from windows? (i've backuped my files using ext2read from windows) –  alvas Sep 13 '12 at 6:37
1  
@Anwar I do not think that he will be able to do that, as there are so many pieces of software that depend on python, that it might be impossible to reinstall them all. And I am not talking about the ubuntu desktop. –  NlightNFotis Sep 13 '12 at 6:45
    
@Anwar: Applications other than from ubuntu-desktop may depend on Python. They were likely removed as well. –  Takkat Sep 13 '12 at 6:47
    
@NlightNFotis and Takkat, yes i just seen that apt also depends on Python. Thanks. –  Anwar Shah Sep 13 '12 at 6:47

If it's not too late for anyone, or if you have come across this problem lately, this is how I got it running:

I followed Mechanical snail's advice and downloaded all the packages using Synaptic. I selected all the relevant packages, basically everything with "python", "python2", "python3", "apt", "python-apt", etc., that was already installed in my computer, tagged them for reinstallation, and when I hit apply, I made sure I downloaded them only.

Then, under root, I went into the /var/cache/apt/archives folder and ran the following command to manually re-install everything I downloaded (you will see all the packages you downloaded with Synaptic in here):

dpkg --unpack *.deb

Anyway, I was getting this apt_pkg error whenever I would get an error message from a Python script in Aptana, and yesterday when I was trying to add a repo. Now at least I can add the repo with no problem, but I'm still getting the apt_pkg error whenever there is an error in my Python scripts...

Running the script outside of Aptana by calling python3.2 or python3 which points at 3.2 works (meaning I get the script's error without the apt_pkg error), but if I run it with python3.3 then the error is back.

share|improve this answer
    
One addition, it seems that it is a bug and this may shed more light unto the issue bugs.launchpad.net/ubuntu/+source/apport/+bug/1059017 –  Roberto Apr 18 '13 at 6:46

OOPS Running this command

sudo apt-get remove --purge python

and watching helplessly removal of all packages embarrassing nothing comes in mind except to bang in room walls, where has the heartbeat gone

why not some warnings given :(:(

share|improve this answer
1  
yes warnings please –  user128334 Sep 4 '13 at 1:11
    
It should be a comment. –  totti Oct 4 at 6:45
1  
It does give you a warning. Remember that huge list of commands that you approved with the "yes" command? –  Whaaaaaat Oct 6 at 16:44

I also had the same problem. And I was able to fix it going to ctrl+alt+f1, logged in with my username and password then:

    sudo apt-get update
    sudo apt-get install --reinstall ubuntu-desktop

And it reinstalled most (if not all) the deleted files (along with unity and terminal) :D

share|improve this answer
    
same for me with cinnamon –  user128334 Sep 4 '13 at 19:10
1  
amazing! my apt-get fails to work after i apt-get remove python... –  alvas Sep 18 '13 at 12:55

you can recover desktop using live CD using chroot http://alok.fossguru.in/content/rescuing-system-chroot

share|improve this answer

You need to execute this: apt-get install ubuntu-desktop
and then apt-get install gdm. When asked lightdm or gdm select gdm.
both as root or using sudo

share|improve this answer
    
by the way, once you apt-get remove python, apt-get will fail to work and complains endlessly... –  alvas Sep 18 '13 at 12:54
    
not if you are fast enough and stop this procedure that kills your entire ubuntu –  George Pligor Sep 18 '13 at 13:02
    
yeah, i was silly enough to let it run until the point where i figured something smells fishy... hahahahaa –  alvas Sep 18 '13 at 13:04

sudo apt-get purge python && sudo apt-get install python2.7
sudo apt-get install python-pip
removes and reinstalls python and pip, then you can install apps like flask, bottle and many others
eg sudo pip install flask
try to install your apps with python

share|improve this answer

During un-installation of Python, I abruptly closed the terminal. Hence Python was partially removed. I fixed it with the following commands

sudo apt-get update
sudo apt-get install --reinstall ubuntu-desktop
sudo apt-get install –-reinstall python-apt
sudo apt-get install –-reinstall python2.7
share|improve this answer

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.