# Ubuntu – Installing Python 3.8.5 from source broke Ubuntu 20.04LTS – how to replace the broken Python install from a backup image of the OS disk

backuppackage-managementpythonpython3software installation

I had the misfortune of trying to install Python 3.8.5 from source tarball manually, and "whoops" — I managed to overwrite my existing Python installation in the process, and, surprise, surprise — my Ubuntu 20.04LTS installation did not like that at all.

I'm running Xubuntu (Xfce4+Ubuntu), so those programs relying on Python 3 libraries went more or less haywire and now, a lot of programs that rely on Python libraries no longer work. Sheesh.

I've been trying to scavenge all possible repair guides (via dpkg, apt, removing the directories, purging, attempting to reinstall, you name it) following just about every possible instruction that's been posted here on AskUbuntu and on StackExchange, none of which have worked out for me.

One reason for that could be that I'm getting arm64 compatibility errors with dpkg/apt uninstall attempts, as I'm running my Ubuntu 20.04LTS on a Raspberry Pi 4B. Many of the dpkg/apt errors pointed specifically to no configuration/install options being available for arm64. Which is probably something that needs to be looked into by the devs.

The possibly bright side is here that I do have a perfect disk image (.img) of the entire OS install (backup often, save a lot of rage!) that I can use to mount and transfer files off from (or, in worst case scenario, overwrite the current install altogether) — it contains the working Python 3.8.x version before this mishap took place, but other than that I'd lose a week's worth of work.

I'm thinking at this point that I'll try to copy the working Python3 version from the backup image version and overwrite all Python3 related files on the install that's now broken as far as Python3 is concerned.

I'm able to use another endpoint to do the copying / rsyncing over the files, but I'd like to know exactly what files should I copy and overwrite from the backup image? Should I just head for /usr/bin/python* and are there any other things to take into consideration? Or is it just a fool's errand at this point and I might as well just re-write the entire system with that 1 week++ old backup and deal with it?

In hindsight… (it being 2020 and all!)If only there'd been a forewarning on Python Foundation's pages on NOT to install a newer version than the one provided by your Linux distribution. Oh well, sometimes you gotta learn things the hard way.

Thanks a lot in advance for any help on this issue.

EDIT: My question got stamped with "This question has already been answered." — Well, I did as instructed at Removed Python 3 and now Ubuntu Software Center, terminal and other applications don't work (where I was pointed to) and things only got from bad to worse.

Someone obviously went TL;DR and completely ignored the point of me just wanting to replace the Python 3.8.5 by overwriting the installation straight off a working backup clone of the OS drive, as nothing else seemed to work. A simple overwrite-copy to Python-related files, that's all.

After following the instructions in the link above (mainly: uninstall python via apt, reboot, reinstall), I only ended up having all my PPA repositories list thrown out the window just like the majority of my previously up-to-date packages, and to top it all off, apt & dpkg are now just throwing out errors as they're desperately trying to downgrade to previous-version packages (newer versions of which were only in the additional PPA repositories) and causing even more cracks in the functionality of the OS overall while at it, since dpkg NOR apt can't seem to solve the issue with the broken packages any longer.

I.e.: sudo apt update now only leads up to:

Hit:1 http://archive.canonical.com/ubuntu focal InRelease Hit:2 http://ports.ubuntu.com/ubuntu-ports focal InRelease Hit:3 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease Hit:4 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease Hit:5 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease Hit:6 http://ports.ubuntu.com/ubuntu-ports focal-proposed InRelease Hit:7 https://apt.llvm.org/focal llvm-toolchain-focal-10 InRelease sh: 1: /usr/lib/cnf-update-db: not found Reading package lists... Done N: Skipping acquire of configured file 'main/binary-arm64/Packages' as repository 'http://apt.llvm.org/focal llvm-toolchain-focal-10 InRelease' doesn't support architecture 'arm64' E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi' E: Sub-process returned an error code

Note to self, and perhaps to future generations (if there are any): "Shooting a mosquito with a bazooka may yield unwanted results." – as for this Ubuntu 20.04LTS install, I'd say it's pretty much FUBAR at this point. Time to just replace the entire install from the backup image. Multiple lessons learned, including that not all proposed solutions over here are exactly helpful. Good day.