11

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
Eugene
  • 111
  • 1
    Please add output of apt-cache policy gdb libpython3.8 to the question. – N0rbert Apr 27 '20 at 13:38
  • This answer solved it for me - given a similar situation of having upgraded to 20.04 after using deadsnakes: https://stackoverflow.com/a/61703923/1773904 – Ian Clark Jan 14 '21 at 15:31

5 Answers5

8

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(Not required)

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

5- finally reboot your pc

That's all :)

Mohamed Ali
  • 101
  • 4
  • Thanks, I had a similar problem after upgrading 18.04 bionic to 20.04 focal where I had previously installed libpython3.8 for bionic from the deadsnakes PPA and this procedure helped me fix the system. – ogrisel May 25 '20 at 08:26
  • Thanks i have similar problem with gcc and build-essntial. I do have to manualy remove Package from /var/lib/apt/status that has ubuntu1~18.04. NOTE: if you do this, don't forget to BACKUP the file – ahmy Jun 06 '20 at 06:42
  • A user reported that this caused their internet to stop working on 20.04, though I do not have any further details. Perhaps more detailed warnings could be added to the answer if it may be harmful if used in certain situations. – Zanna Aug 25 '20 at 16:05
  • Step 3 can be simplified, because apt can handle a list of packages: sudo apt-get install package-x package-y https://askubuntu.com/questions/874611/installing-multiple-packages-at-the-same-time – nevrome Dec 07 '22 at 14:46
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

1

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.

mrts
  • 311
1

Just an FYI, another possible reason for held back packages, they can be manually held back too:

sudo apt-mark hold (package) will hold a package: it blocks upgrading it for any reason. You can use dpkg to install an older version of some package or packages if you want, but usually as soon as you ran your updates it'd be updated to the current version; apt-mark hold'ing it prevents this, but also prevents upgrading it during an Ubuntu upgrade if the holds aren't removed first).

apt-mark showholds lists any active holds.

apt-mark unhold (package) un-holds a package: the system is free to update those packages again.

I've used this twice; once, to reinstall and hold squid 3.xx on my Ubuntu 20.04 system, since squid 4.xx did not work for my use case. On a ARM Chromebook, it came with nice nvidia drivers that even supported CUDA if you kept its customized Linux kernel and Ubuntu 16.04-era X server..; I upgraded to 18.04 holding back like a dozen X-related packages... boom! Fully up-to-date Ubuntu 18.04 with the Ubuntu 16.04 X stuff so the nvidia driver kept running, even the CUDA. holds can be pretty sweet if you need them.

Zanna
  • 70,465
hwertz
  • 326
  • 2
  • 4
-4

I was able to upgrade one system today and I noticed something in the process that I will share ...

The one system that I upgraded from 18.04 to 20.04 required several (about 5) sets of update && upgrade. During the final two, I received notice that there was much more to update and indications of file uploads in addition to what I had already done. During the last "sudo apt upgrade" command in Terminal, I received a notice of a large number of upgrades. It didn't indicate that they were the upgrade to 20.04, but it turned out that they were. To get this to happen, Updates needed to be set "For any version." This machine is working!

The second computer I simply wiped. Did a backup of data only to another disk and inserted a live USB and followed the instructions. I did this after getting repeated error messages that there were broken packages and missing files. I needed to end the frustration.

The third machine is an old one. This laptop has been upgraded from 14.04 to 16.04, to 18.04 (all LTS's). There's lots of legacy stuff, including some i386 files and programs. This one will not upgrade! Random error messages include one file not upgraded; 7 files not upgraded; 12 files not upgraded; Upgrades to the development release are only available from the latest supported release; going to Software Updater (GUI) I will receive notice of additional files to be loaded, sometimes 3, sometimes 6, and every number in between; and I receive notice that there is something wrong with my internet connection or the server; etc. Much of this is the same process that I went through with the first computer.

And, this is my guess ... The 20.04 release is so new and so many people are downloading it that the server cannot handle the traffic (I've tried other servers with the same results). The updates and upgrades are being fed to my computer piecemeal. Here's what I've done: - In Terminal - sudo update && upgrade, then sudo do-release-upgrade -d - In Updater (GUI) - Click settings and then Updates, alternately setting Updates to "... any new version" and then to "... long term support version"; also try a different server.

It's exasperating, but I think the only thing we can do is continue to work with the computer, putting in the same commands; alternate using the Terminal and the Updater (GUI) until eventually we get to the holy grail ... and UPGRADE!