-1

I have a Ubuntu 20.04 LTS version(I am new to Ubuntu), recently I wanted to install the latest version of python i.e. python3.10.0 but was not able to so I looked online and followed many methods but not remember which one worked hence, I won't be able to tell what I used.Then the next day when I tried to open the terminal it was not working so I looked up the internet and it said that it might be because of the recent things I installed and as the latest thing I did was to install python and I remembered a warning regarding the installation of python3.10.0 that came up during the installation process but I ignored it so, I thought of removing python from the system I did that using something as Clt+Alt+F3 but I messed up the python of the OS. Since then many applications are not opening including terminal, is there a way to fix this without installing Ubuntu20.04 again because I don't want to do the process again and then install the third party packages once more and also my important files will be lost. I want a solution that will repair whole OS without disturbing much of apps and packages(It is okay if some apps and packages are removed but not all)

Note: I have synaptic package manager,dconf-editor,gdebi package manager if needed I can use them.

Edit: If everything is removed it is okay and I have created backup for files but don't want to install it over again.

2 Answers2

0

I accidentally deleted python3 under /usr/lib on Ubuntu 20; you could've messed it one way or another as well; my system afterwards won't update, launch the terminal or run software updates. You do NOT need to reinstall your Ubuntu.

Here is how I solved the problem:

  1. boot your system from a USB Ubuntu stick
  2. Do not install, choose to "Try Ubuntu"
  3. Launch the terminal on your Ubuntu (which you are running in try mode on the USB stick).
  4. Open two tabs in terminal:
    • one that is pointing to your local Ubuntu stick path /usr/lib
    • another pointing to "Other locations" where you point to the local drive of your computer's /usr/lib. Typically under /media/some hash code/../usr/lib
  5. from properties, copy the path of your /usr/lib of your mounted drive on you PC. It would be something under /media path.
  6. cp -r /usr/lib/python3 into your mounted local drive path on your PC where /usr/lib is. If you had messed it up, delete the local one, and copy the one from the usb stick.
  7. Shutdown your running Ubuntu (try-mode on USB stick) and Start Ubuntu on your PC as usual.
  8. You will need to fix some apport dependencies that are installed already on your system, but are not yet hooked to your system's python3 environment. To do that:
    1. Open the original terminal that comes with Ubuntu. You can do that now from the applications' launcher, or Ctrl+Meta+Alt+F3 to go to tty terminal (to go back to Gnome Ctrl+Meta+Alt+F1).

    2. When you open the terminal, you get an error message before the prompt. Read through, and it is already naming a missing package.

    3. The named missing package(s) are not pip installable, rather apt installed. Install the respective package with the command:

      apt -f install --reinstall <package name>
      
    4. Then close the terminal, and reopen again the terminal. You will need to do that incrementally. So, you will get another name for a missing python package being imported by python but not found. Again, install it the same way with apt as above. Incrementally doing so until all errors are gone, and all hooks are re-established.

    5. Finally, run:

      sudo apt install --reinstall ubuntu-desktop
      

      P.S. note that, if you had gnome-tweaks installed, you will need to reinstall it as well:

      sudo apt install --reinstall gnome-tweaks
      

And you are done.

matigo
  • 24,752
  • 7
  • 50
  • 79
-1

Try this:

$ apt -f install Reboot. If it's still not right, try: $ dpkg-reconfigure -a Reboot. It should be working for sure, unless you messed up the package database in /var Let us know how it goes. Write down all the errors, in case we need them to further assist you.

I wouldn't worry. I used to get into a mess all the time. It's how you learn!

Brian
  • 374