Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35

Thread: Removed python, how do I put it back?

  1. #1
    Join Date
    Mar 2008
    Beans
    209

    Removed python, how do I put it back?

    I did a dumb thing, which was removing python2 and 3 from my Lubuntu 20.04LTS distro. (After running a snap and "integrating it" icons on my system vanished, I followed a thread down the rabbit hole and it seemed like a good idea at the time. Only it wasn't.)

    I did "sudo apt remove python3" and then the same for python2. Dunce hat move, I know.

    Now, it won't even boot...just hangs at the launch screen with the five little blue dots loading. I tried accessing it via SSH to see if I could use a terminal, but no, it's totally bricked, apparently.

    I'm running on a Live USB, but would love to know how I can restore this back to its normalness of a few days ago...if possible. Is there a way to -- using a Live USB -- somehow run apt install? Or, perhaps through dpkg?

    Thank you for any and all help or suggestions. Alternately, if I can upgrade to 22.04LTS without risking losing my /home directory, I could do that too, but I'd rather just try to get the old system booting again.

  2. #2
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,952

    Re: Removed python, how do I put it back?

    It's possible. I've done it.

    For most users, it's much, much easier to use the Live environment to back up their data and then reinstall.

    First, you need to know exactly which packages you removed. Exact versions help, too.
    Second, you need to know how to chroot your broken system from the Live environment. If you are unfamiliar with chrooting, look it up.
    Third, you need to understand how deb dependencies work, and how to use dpkg.

    Those are all fairly easy. The critical skill that determines success or failure is reading and understand dpkg output in order to make the right choices.
    Folks who don't read the output (or don't understand it) are almost certain to fail.
    Your problem is that you already ignored that output at least once and made the wrong choice -- that's how you got into the current mess.

    The basic theory is that you download the python3, python3.x, python3-minimal, and python3.x-minimal packages from packages.ubuntu.com.
    Make sure you download the correct versions.
    Use dpkg (not apt) to install them. If you get a dependency error, then download and install that dependency.
    After those four packages...and their dependencies...are successfully installed, apt should work again. Use apt to restore any other packages that you removed.

    If you need more instruction than that, then you're not ready to do the repair. Go the backup-and-reinstall route instead.
    Last edited by ian-weisser; December 20th, 2023 at 06:02 AM.

  3. #3
    Join Date
    Mar 2010
    Location
    USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Removed python, how do I put it back?

    If that is all you did, then first try
    Code:
    sudo apt install --reinstall -y python3
    If that fails, then try
    Code:
    wget -N -t 5 -T 10 http://mirrors.kernel.org/ubuntu/pool/main/p/python3-defaults/python3_3.8.2-0ubuntu2_amd64.deb
    sudo dpkg -i ./python3_3.8.2-0ubuntu2_amd64.deb
    If that fails, then chroot into your installed system from a Focal Installer LiveUSB, then reinstall it using the first method above...

    "Concurrent coexistence of Windows, Linux and UNIX..." || Ubuntu user # 33563, Linux user # 533637
    Sticky: Graphics Resolution | UbuntuForums 'system-info' Script | Posting Guidelines | Code Tags

  4. #4
    Join Date
    Mar 2008
    Beans
    209

    Re: Removed python, how do I put it back?

    Thank you @MAFoElffen, can you quickly verify that what you're suggesting works when I'm running off a Live CD? If I apt install something, won't that be into the Live CD environment? Do I need to chroot first, then try what you suggest?

    (Asking only because this looks vastly easier and I think all I did was remove python3 and python2, so hopefully I could just reinstall those as written instead of having to know the detailed info from the remove command.)

    Thank you and @ian-weisser for the suggestions! Really appreciate it.

  5. #5
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Removed python, how do I put it back?

    When you chroot into your installed OS the commands you run will act on that installed system, not the live system so any changes will be to that installed system.

  6. #6
    Join Date
    Mar 2010
    Location
    USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Removed python, how do I put it back?

    Can you boot into the installed system still... If so, then try to do the first two from that.

    If not, then do it from a LiveUSB. If from a LiveUSB, then yes, you would have to do everything "AFTER" chrooting into the installed system.

    If you need help chrooting into your installed system, I would need to know some information from that system. If you use the UbuntuForums 'system-info' script in my signature line from a LiveUSB, then posted the URL of where the report uploads to a pastebin, then I could lead you through that on your system.

    Most everything on Linux (Not just Ubuntu) depends very heavily from Python. This is something that needs to be restored. It can be done, without having to reinstall, as long as you don't make things worse. LOL.

    "Concurrent coexistence of Windows, Linux and UNIX..." || Ubuntu user # 33563, Linux user # 533637
    Sticky: Graphics Resolution | UbuntuForums 'system-info' Script | Posting Guidelines | Code Tags

  7. #7
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Removed python, how do I put it back?

    If I remember correctly an active python is required for apt to work so having removed it from your system the chroot method mentioned may be your only way to deal with the problem other than reinstalling.
    Last edited by ajgreeny; December 20th, 2023 at 09:32 AM. Reason: Typo

  8. #8
    Join Date
    Mar 2010
    Location
    USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Removed python, how do I put it back?

    I thought so to... But it actually worked for someone a few weeks ago... where it was removed but not purged. That surprised the heck out of me!

    Besides doing the second method (download and use dpkg) is outside of the apt system and will not hurt it any more than it already is. LOL

    Worth a quick try before talking him through chroot'ing into his system.
    Last edited by MAFoElffen; December 20th, 2023 at 01:43 AM.

    "Concurrent coexistence of Windows, Linux and UNIX..." || Ubuntu user # 33563, Linux user # 533637
    Sticky: Graphics Resolution | UbuntuForums 'system-info' Script | Posting Guidelines | Code Tags

  9. #9
    Join Date
    Aug 2017
    Location
    melbourne, au
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Removed python, how do I put it back?

    I would expect a system to boot normally even after removing python3/2; though you may find the GUI is not very usable (if you can even achieve login; it appears you cannot), but text terminal should still operate.

    I wouldn't expect `apt` to work, but if it doesn't, `dpkg` install (as suggested by MAFoElffen) will allow fixing the issue, with `python3-minimal` being all you should need installed before normal operation is returned.

    You likely know, but Lubuntu 20.04 LTS is EOL - https://lubuntu.me/lubuntu-20-04-lts...port-statuses/

  10. #10
    Join Date
    Mar 2010
    Location
    USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Removed python, how do I put it back?

    Dang. I keep forgetting that even though LTS, that flavors are only 3 years of support instead of 5 years like Ubuntu LTS.

    "Concurrent coexistence of Windows, Linux and UNIX..." || Ubuntu user # 33563, Linux user # 533637
    Sticky: Graphics Resolution | UbuntuForums 'system-info' Script | Posting Guidelines | Code Tags

Page 1 of 4 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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