3

After updating to version 20.04 (forcefully using -d command), I am not able to update or upgrade neither using termical nor using software now.

import apt_pkg  
ImportError: libapt-pkg.so.6.0: cannot open shared object file: No such file or directory  
Reading package lists... Done  
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  

This returned in the last while trying to update, also I have a red marker beside the battery icon which says the same "a problem occurred when checking for updates"

Contents at cd /etc/apt/sources.list.d/

-rw-r--r-- 1 root root 221 Aug 27 23:59 google-chrome.list  
-rw-r--r-- 1 root root 189 Aug 27 23:20 google-chrome.list.distUpgrade  

Any help would be appreciated. I am new to Ubuntu.

Edit: sudo apt upgrade gives this error:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
 dirmngr : Depends: init-system-helpers (>= 1.52) but 1.51 is installed
 gir1.2-gtk-3.0 : Depends: gir1.2-gdkpixbuf-2.0 (>= 2.40.0) but 2.36.11-2 is installed
                  Depends: gir1.2-pango-1.0 (>= 1.41.0) but 1.40.14-1ubuntu0.1 is installed
                  Depends: libgtk-3-0 (>= 3.24.7) but 3.22.30-1ubuntu4 is installed
 gnupg : Depends: gpgv (>= 2.2.19-3ubuntu2)
 gpg-agent : Depends: init-system-helpers (>= 1.52) but 1.51 is installed
 hplip : Depends: hplip-data (= 3.20.3+dfsg0-2) but 3.17.10+repack0-5 is installed
         Depends: libhpmud0 (= 3.20.3+dfsg0-2) but 3.17.10+repack0-5 is installed
         Depends: printer-driver-hpcups (= 3.20.3+dfsg0-2) but 3.17.10+repack0-5 is installed
         Depends: libpython3.8 (>= 3.8.2) but it is not installed
 libsane-hpaio : Depends: libhpmud0 (>= 3.20.3+dfsg0) but 3.17.10+repack0-5 is installed
 python3-apt : Depends: libapt-pkg6.0 (>= 1.9.11~) but it is not installed
 python3-brlapi : Depends: libbrlapi0.7 but it is not installed
 python3-gi : Depends: libgirepository-1.0-1 (>= 1.62.0-4~) but 1.56.1-1 is installed
 python3-pil : Depends: libimagequant0 (>= 2.11.10) but it is not installed
 python3-protobuf : Depends: libprotobuf17 but it is not installed
 python3-uno : Depends: libreoffice-core (= 1:6.4.5-0ubuntu0.20.04.1) but 1:6.0.7-0ubuntu0.18.04.10 is installed or
                        libreoffice-core-nogui (= 1:6.4.5-0ubuntu0.20.04.1) but it is not installed
               Depends: libpython3.8 (>= 3.8.2) but it is not installed
               Depends: libuno-cppu3 (>= 4.4.0~alpha) but it is not installed
               Depends: libuno-cppuhelpergcc3-3 (>= 5.3.0~alpha) but it is not installed
               Depends: libuno-sal3 (>= 5.4.0~alpha) but it is not installed
               Depends: libuno-salhelpergcc3-3 (>= 3.6.0~beta) but it is not installed
               Depends: uno-libs-private but it is not installed
 rhythmbox-plugins : Depends: librhythmbox-core10 (= 3.4.4-1ubuntu2) but 3.4.2-4ubuntu1 is installed
                     Depends: rhythmbox (= 3.4.4-1ubuntu2) but 3.4.2-4ubuntu1 is installed
                     Depends: gir1.2-rb-3.0 (= 3.4.4-1ubuntu2) but 3.4.2-4ubuntu1 is installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies```
Dude901
  • 71
  • 1
    then why dont you do this sudo dpkg --configure -a – sonu ishaq Aug 28 '20 at 05:46
  • Similar issue here: https://askubuntu.com/questions/1238254/partial-upgrade-to-20-04-lts-incorrect-version-of-libapt-pkg – pLumo Aug 28 '20 at 07:01
  • @sonuishaq, I tried but this came up for a lot of packages Depends: , but it is not installed followed by Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). Afterwards I apt --fix-broken install which gave Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root? – Dude901 Aug 28 '20 at 10:06
  • sudo apt --fix-broken install – sonu ishaq Aug 29 '20 at 11:30
  • added the output in the question of the command – Dude901 Aug 29 '20 at 11:32
  • @Dude901 It says "are you root?", which means you'll need sudo. sudo apt --fix-broken install – Archisman Panigrahi Aug 29 '20 at 11:38
  • @ArchismanPanigrahi I did use sudo, the snap is of the same. I'll share the complete output. – Dude901 Aug 29 '20 at 11:53
  • hi Any solution to this problem? I faced the same thing today and now I cant install anything using apt-get – jarvo69 Oct 21 '20 at 14:19
  • @SumitBadaya No, nothing worked out for me so I had to reinstall. – Dude901 Oct 22 '20 at 11:31
  • yeah same here...I also reinstalled from a ISO file and then only it worked out. Lost some data but took backup of imp stuff before reinstalling – jarvo69 Oct 24 '20 at 14:37
  • Run sudo aptitude -f upgrade – Error404 Oct 30 '21 at 01:57

1 Answers1

-2

Perhaps someone can explain why the following worked for me.

My upgrade from Ubuntu 18 to 20 was interrupted and I knew it was not completed. So I ran sudo apt update and sudo apt upgrade and got the following errors which are very similar to the OP's.

sudo apt update

Traceback (most recent call last): File "/usr/lib/cnf-update-db", line 8, in <module> from CommandNotFound.db.creator import DbCreator File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module> import apt_pkg ImportError: libapt-pkg.so.6.0: cannot open shared object file: No such file or directory Reading package lists... Done 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

sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 gnupg : Depends: gpgv (>= 2.2.19-3ubuntu2.1) but 2.2.4-1ubuntu1.4 is installed
 gnupg-utils : Depends: libreadline8 (>= 6.0) but it is not installed
 gpg : Depends: libreadline8 (>= 6.0) but it is not installed
 gpgconf : Depends: libreadline8 (>= 6.0) but it is not installed
 gpgsm : Depends: libreadline8 (>= 6.0) but it is not installed
 grub-common : Depends: libefiboot1 (>= 37) but it is not installed
               Depends: libefivar1 (>= 37) but it is not installed
 grub2-common : Depends: libefiboot1 (>= 37) but it is not installed
                Depends: libefivar1 (>= 37) but it is not installed
 initramfs-tools-core : Depends: initramfs-tools-bin (= 0.136ubuntu6.6) but 0.130ubuntu3.13 is installed
                        Depends: lz4 but it is not installed
 klibc-utils : Depends: libklibc (= 2.0.7-1ubuntu5) but 2.0.4-9ubuntu2 is installed
 libpython3.8-stdlib : Depends: libreadline8 (>= 7.0~beta) but it is not installed
 python3-apt : Depends: libapt-pkg6.0 (>= 1.9.11~) but it is not installed
 systemd-sysv : Depends: systemd (= 245.4-4ubuntu3.13) but 237-3ubuntu10.52 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

running sudo apt --fix-broken install

did not resolve any of them. However, I then ran all of the following commands:

sudo apt --fix-broken install gnupg
sudo apt --fix-broken install gnupg-utils
sudo apt --fix-broken install gpg
sudo apt --fix-broken install gpgconf
sudo apt --fix-broken install gpgsm
sudo apt --fix-broken install grub-common
sudo apt --fix-broken install grub2-common
sudo apt --fix-broken install initramfs-tools-core
sudo apt --fix-broken install klibc-utils
sudo apt --fix-broken install libpython3.8-stdlib
sudo apt --fix-broken install python3-apt
sudo apt --fix-broken install systemd-sysv

Note that after running each of these commands, it seemed that I was making no progress (the same error message above, was displayed after each -- The following packages have unmet dependencies: with the list of dependencies displayed after running each of these commands).

However, after running all of those commands, the following worked:

sudo apt --fix-broken install

After rebooting and running sudo apt update and sudo apt upgrade, the upgrade from Ubuntu 18 to Ubuntu 20 was complete.

David
  • 97
  • This post explains some other commands which when done first, apparently allowed apt --fix-broken install to work. – David Oct 30 '21 at 02:03
  • Top tip: Starting an answer with Perhaps someone can explain why the following worked for me. makes it look like a question-posted-as-an-answer – Greenonline Oct 30 '21 at 03:22
  • @Greenonline Which is more important -- looking like an answer, or being an answer? It is a partial answer which is better than nothing, and is up front about being imperfect and incomplete. You are invited to edit it and make it better, or offer a competing more perfect and more complete answer. There is such a thing as a partial answer, which may include further questions and barely begin to answer the original question; such partial answers from novices may in some cases enrich the community as much as perfect answers from experts. Perfect is the enemy of the good. – David Oct 30 '21 at 18:53