部分升级至 20.04 LTS - libapt-pkg 版本不正确

部分升级至 20.04 LTS - libapt-pkg 版本不正确

我正在尝试从 18.04 升级到 20.04:

$ grep -i rel /etc/lsb-release 
DISTRIB_RELEASE=20.04

看起来存在依赖性问题:

$ sudo apt-get update
Hit:1 http://no.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://no.archive.ubuntu.com/ubuntu focal-updates InRelease       
Hit:3 http://no.archive.ubuntu.com/ubuntu focal-backports InRelease     
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
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
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ImportError: libapt-pkg.so.6.0: cannot open shared object file: No such file or directory

Original exception was:
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

我好像有旧的libapt-gpu.so.5.0而不是新的和预期的libapt-pkg.so.6.0

sudo updatedb && locate libapt-pkg.so
/usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0
/usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0.2

关于如何修复有什么提示吗?

根据 MA​​V 的帮助提示进行更新:

$ wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/libapt-pkg6.0_2.0.2ubuntu0.1_amd64.deb
$ sudo dpkg -i libapt-pkg6.0_2.0.2ubuntu0.1_amd64.deb 
$ sudo apt-get update
Reading package lists... Done  
$ sudo apt-get 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:
<..lot of packages..>
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
 gir1.2-gdkpixbuf-2.0 : Breaks: gir1.2-gdkpixbuf-2.0:i386 (!= 2.36.11-2) but 2.40.0+dfsg-3 is installed
 gir1.2-gdkpixbuf-2.0:i386 : Depends: gir1.2-glib-2.0:i386 (>= 0.9.3) but it is not installed
                             Depends: libgdk-pixbuf2.0-0:i386 (>= 2.39.2) but it is not installed
                             Breaks: libgtk3-perl (< 0.034-2~) but 0.032-1 is installed
                             Breaks: gir1.2-gdkpixbuf-2.0 (!= 2.40.0+dfsg-3) but 2.36.11-2 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)
 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
 libsane-hpaio : Depends: libhpmud0 (>= 3.20.3+dfsg0) but 3.17.10+repack0-5 is installed
 python3-brlapi : Depends: libbrlapi0.7 but it is not installed
 python3-dev : Depends: libpython3-dev (= 3.8.2-0ubuntu2) but 3.6.7-1~18.04 is installed
               Depends: python3.8-dev (>= 3.8.2-1~) 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.3-0ubuntu0.20.04.1) but 1:6.0.7-0ubuntu0.18.04.10 is installed or
                        libreoffice-core-nogui (= 1:6.4.3-0ubuntu0.20.04.1) 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

我假设你的 arch 是 amd64。

cd /tmp;wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/libapt-pkg6.0_2.0.2ubuntu0.1_amd64.deb;sudo dpkg -i libapt-pkg6.0_2.0.2ubuntu0.1_amd64.deb从终端尝试一下,看看是否可以让你开始。

aptitude search ~b您提到了 aptitude 标签。如果上述命令序列无法帮助您解决问题,请发布输出。

答案2

上述命令在 Ubuntu 20.04 上对我有效,但我仍然收到如下错误:

$ sudo apt-get upgrade 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
/usr/lib/ubuntu-advantage/apt-esm-hook: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
/usr/lib/ubuntu-advantage/apt-esm-hook: error while loading shared libraries: libapt-pkg.so.5.0: cannot open shared object file: No such file or directory

我设法通过重新安装来克服它ubuntu-advantage-tools

sudo apt-get install -y ubuntu-advantage-tools

相关内容