Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Removed Python2.7 by mistake


    I'm a newbie and I think I've done something silly. I'm using Ubuntu - I was following instructions in a magazine doing some basic Python programming - I came across a problem and thought it was to do with Python 2.7 - Python 3 was present in /etc so I thought it would be OK to remove Python 2.7 with (pretty sure this was the command I used) "apt-get remove python2.7". After rebooting the laptop Ubuntu doesn't boot properly.

    It boots up so far - gets as far as starting X but doesn't allow me to get to any applications or terminal window etc. I can boot up in recovery mode so I'm wondering if someone can point me in the right direction to restore without reinstalling.

    Thanks !


  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Virginia, USA
    Interesting problem. Well, you can obviously try reinstalling python2.7. The issue is, with such a pivotal package, many other packages were uninstalled with it. When you remove a package, apt-get will also uninstall the packages that depend on that package. There's no telling what packages were removed. You'll have to look for the packages that were uninstalled in /var/log/apt/history.log

    You can run grep Remove /var/log/apt/history.log | awk '{print $2}' > removed.out
    Then remove whichever packages you DON'T want to be installed from that file.
    Then, cat removed.out | xargs apt-get install -y --force-yes

    That is about as automated as you're going to get. One thing to keep in mind, some packages and whatnot are setup automatically during installation when you install the system. Since you're just installing packages, you shouldn't break too much
    I would take a back up of any important files before this operation just to be safe.

  3. #3
    Thanks very much Mizzle ! I didn't realise Python was so pivotal - I won't be making that mistake again !

    I'll give those instructions a go and let you know how I get on.

    Thanks again !!

  4. $spacer_open
  5. #4
    Hey Mizzle,

    I did that - file system wasn't mounted so I had to

    mount -o remount /

    Did the grep command and it returned an empty removed.out file - the xargs therefore didn't return any installations.

    I tried

    apt-get install python2.7

    but that gave the same 0 installation response - install is the same as it was.

    Any ideas ?

  6. #5
    Linux Engineer
    Join Date
    Apr 2012
    Virginia, USA
    Are you booting from a LiveCD? I assumed you were booting into single user mode or what have you.
    If you are booting from a live cd, you need to mount the root file system of your disabled system somewhere.
    mkdir /tempmnt
    mount /dev/sda1 /tempmnt
    or whatever disk/partition is. A few more steps required for LV's.
    Anyway, then
    chroot /tempmnt

    You may or may not be able to install software using apt-get. Not sure what all removing python2.7 will break.

    If you are booted onto the system via single user mode, and the apt log is empty, there may be another file in that directory. Something that is gzipped. You can use zcat to cat that file and perform a similar action against it.

    zcat <file> | grep Remove | awk '{print $2}' > removed.out

  7. #6
    Thanks Mizzle !

    I can't boot from a live CD - this laptop doesn't have a CD drive so I'm kind of dependent on downloading whatever I need. I boot in recovery mode and one of the options is to turn networking on but that ends at "serial port closed" and hangs for a while. Is there a command to turn on the wireless networking from root - that would make it a bit easier. I did manage to get the wireless working once and was able to

    dpkg --configure -a

    that went off and downloaded a load of stuff without errors

    I found somewhere else instructions to

    apt-get install gdm

    but haven't been able to get that going as the wireless is sporadic through recovery mode - I'm thinking the command to get the networking going might be

    service network restart

    but not sure

  8. #7
    Linux Engineer
    Join Date
    Apr 2012
    Virginia, USA
    It's tough getting wireless working in CLI mode. Not my area of expertise. I suggest using an ethernet cable if possible.

  9. #8
    haha my thoughts exactly mizzle - I tried last night without much success ! I'll give the cable a go and let you know how I get on - I've got a feeling with everything you've said above and a few things I googled that I'll get it going - alternatively I'll get it on the network at work and install fresh over the network - somehow

    Thanks !!

  10. #9
    Linux Engineer MASONTX's Avatar
    Join Date
    May 2010
    Mason Texas
    It is educational to find and fix the problem, but it is often quicker to just back up your files and reinstall.
    Registered Linux user #526930

  11. #10
    thanks for your replies - I eventually got around to reinstalling Ubuntu and it's now working fine ! As I don't have a DVD drive I bought an external one and installed afresh - I even took the plunge and manually deleted partitions that had dead installs on - leaving my Windows partition as it was and creating some swap space and an ext4 logical partition and the install couldn't have gone better - I'm now having a bit of an issue with ssh to a remote server but hey I'll get to the bottom of that I'm sure

    Thanks again !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts