How to fix update problems (Ubuntu 20.04)

I had finished the update to Ubuntu 20.04 and was trying to update the packages as well but I encountered an error with one of my packages being held. This is the output after running "sudo apt upgrade":

Reading package lists...
Done Building dependency tree
Reading state information...
Done Calculating upgrade... 
Done The following packages have been kept back:   
gdb gir1.2-peas-1.0 libpeas-1.0-0 libsmbclient libwbclient0 samba-libs 
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

I have tried running multiple commands to clear broken packages/dependencies, including:

sudo apt clean
sudo apt autoclean
sudo apt autoremove

Nothing seems to work (not even dist-upgrade does anything) and when I tried manually updating the packages I got the following message:

sudo apt-get install gdb

The following packages have unmet dependencies:
 gdb : Depends: libpython3.8 (>= 3.8.0~a1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I have tried many more things without any results so I was wondering what my options are.

Running apt cache policy gbd libpython3.8 produces the output:

gdb:
  Installed: 8.1-0ubuntu3.2
  Candidate: 9.1-0ubuntu1
  Version table:
     9.1-0ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages
 *** 8.1-0ubuntu3.2 100
        100 /var/lib/dpkg/status
libpython3.8:
  Installed: (none)
  Candidate: 3.8.2-1ubuntu1
  Version table:
     3.8.2-1ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

Solution 1:

I had this problem too and this is how i fixed it

Befor all don't forget this two points :

-- 1 -- Do not reboot your PC until you finish all the steps

-- 2 -- Do not forget to update your grub befor rebooting by executing : sudo update-grub2

The problem here is that when you upgrade ubuntu from 18.04 to 20.04 the system did not replace every instance of bionic with focal : it did not replace libpython3.8-stdlib (3.8.2-1+bionic1) by libpython3.8-stdlib (= 3.8.2-1ubuntu1.1) So the solution is to replace it manually :) The steps to do this are :

1 - save the names of the packages that depend on the library in a text file to reinstall them later run : sudo apt-get autoremove libpython3.8-stdlib a message will show you all this packages :

(( apg apparmor apport apport-gtk ...xserver-xorg-video-vmware xwayland yelp yelp-xsl ))

copy them in a text file, then tap " yes " to uninstall the bionic version of libpython3.8-stdlib

2- install the focal version by :

sudo apt-get install libpython3.8-stdlib

3- now install the packages saved in the text file one by one : you can create a screipt file like this : (( ....

sudo apt-get install gir1.2-gck-1
sudo apt-get install gir1.2-gcr-3
sudo apt-get install gir1.2-gdm-1.0
sudo apt-get install gir1.2-geoclue-2.0
sudo apt-get install gir1.2-gnomebluetooth-1.0

... ))

Do not forget to install the ubuntu-desktop if it is not in the package text file sudo apt-get install ubuntu-desktop

4- update your grub , run : sudo update-grub2

5- finally reboot your pc

That's all :)

Solution 2:

I too had this problem due to using the deadsnakes ppa and fixed it using a few simple steps:

# sudo apt list --upgradable
  Listing... Done
  gdb/focal-updates 9.2-0ubuntu1~20.04 amd64 [upgradable from: 8.1.1-0ubuntu1]
  gir1.2-peas-1.0/focal,focal 1.26.0-2 amd64 [upgradable from: 1.22.0-2]
  libpeas-1.0-0/focal,focal 1.26.0-2 amd64 [upgradable from: 1.22.0-2]
  libsmbclient/focal-updates,focal-security 2:4.11.6+dfsg-0ubuntu1.6 amd64 [upgradable from: 2:4.7.6+dfsg~ubuntu-0ubuntu2.21]
  libwbclient0/focal-updates,focal-security 2:4.11.6+dfsg-0ubuntu1.6 amd64 [upgradable from: 2:4.7.6+dfsg~ubuntu-0ubuntu2.21]
  samba-libs/focal-updates,focal-security 2:4.11.6+dfsg-0ubuntu1.6 amd64 [upgradable from: 2:4.7.6+dfsg~ubuntu-0ubuntu2.21]

# python3 --version
  Python 3.8.8

# sudo apt list | grep python3.8
  ==> few entries were pointing to bionic

# sudo rm -f /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa*

# sudo apt-get install gdb/focal gir1.2-peas-1.0/focal libpeas-1.0-0/focal python3.8/focal python3.8-minimal/focal libpython3.8/focal libpython3.8-minimal/focal libpython3.8-stdlib/focal

# sudo apt update

# sudo apt list --upgradable

# sudo apt upgrade

# sudo apt upgrade samba-libs

# sudo apt list --upgradable 
  Listing... Done
# sudo apt update
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  All packages are up to date.

# sudo apt list | grep python3.8
  ==> all entries should point to focal

Solution 3:

I ended up in a similar situation because I had installed Python 3.8 from the deadsnakes PPA in 18.04, so the system Python 3.8 packages were held back. I had to run

sudo apt-get purge libpython3*

to get rid of the deadsnakes packages.

Beware! As Mohamed Ali warned, this will remove most of the Ubuntu packages and make your system unusable. Don't reboot before you have reinstalled the system.

Then I reinstalled the system with

sudo apt install ubuntu-desktop

Everything works well now after a clean start.