更新到版本 20.04 后(强制使用 -d 命令),我现在无法使用 termical 或使用软件进行更新或升级。
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
上次尝试更新时又出现了这个问题,而且电池图标旁边还有一个红色标记,上面写着“检查更新时出现问题”
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
任何帮助都将不胜感激。我是 Ubuntu 新手。
编辑:
sudo apt upgrade
给出此错误:
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```
答案1
也许有人可以解释为什么以下内容对我有用。
我从 Ubuntu 18 升级到 20 时中断了,我知道升级没有完成。所以我运行了 sudo apt update 和 sudo apt upgrade,结果出现了以下错误,与楼主的错误非常相似。
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).
跑步
sudo apt --fix-broken install
没有解决任何问题。但是,我随后运行了以下所有命令:
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
请注意,运行完每个命令后,似乎没有取得任何进展(每个命令后都会显示上述相同的错误消息 -The following packages have unmet dependencies:
运行完每个命令后都会显示依赖项列表)。
但是,运行所有这些命令之后,以下内容有效:
sudo apt --fix-broken install
sudo apt update
重新启动并运行后sudo apt upgrade
,从 Ubuntu 18 到 Ubuntu 20 的升级就完成了。