由于未满足依赖关系,无法使用 apt-get

由于未满足依赖关系,无法使用 apt-get

之前发布过类似的问题这里但那篇文章中的答案对我来说不起作用。

我的问题如下,当我尝试安装 en 包或运行 autoremove 时,我得到:

emiel@server:~$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 ghostscript : Depends: libgs9 (= 9.18~dfsg~0-0ubuntu2.7) but it is not     installed
 libspectre1 : Depends: libgs9 (>= 8.61.dfsg.1) but it is not installed
E: Unmet dependencies. Try using -f.

因此,按照建议,我尝试了“sudo apt-get install -f”,但出现以下错误:

emiel@server:~$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer 
required:
  libllvm3.8 libmircommon5 linux-headers-4.4.0-81 linux-headers-4.4.0-81-generic linux-headers-4.4.0-83 linux-headers-4.4.0-83-generic linux-headers-4.4.0-89
  linux-headers-4.4.0-89-generic linux-image-4.4.0-81-generic linux-image-4.4.0-83-generic linux-image-4.4.0-89-generic linux-image-extra-4.4.0-81-generic
  linux-image-extra-4.4.0-83-generic linux-image-extra-4.4.0-89-generic linux-signed-image-4.4.0-81-generic linux-signed-image-4.4.0-83-generic linux-signed-image-4.4.0-89-generic
  snap-confine
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libgs9
The following NEW packages will be installed:
 libgs9
0 upgraded, 1 newly installed, 0 to remove and 173 not upgraded.
42 not fully installed or removed.
Need to get 0 B/2057 kB of archives.
After this operation, 16,2 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Selecting previously unselected package libgs9:amd64.
dpkg: warning: files list file for package 'libcurl3:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'crda' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libsasl2-modules-db:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libudisks2-0:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libsasl2-2:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libhogweed4:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libubuntutoolkit5:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libusb-1.0-0:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'liburi-perl' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'liburl-dispatcher1:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'cron' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libusb-0.1-4:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libubuntugestures5:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libsane-hpaio:amd64' missing; assuming package has no files currently installed
(Reading database ... 388901 files and directories currently installed.)
Preparing to unpack .../libgs9_9.18~dfsg~0-0ubuntu2.7_amd64.deb ...
Unpacking libgs9:amd64 (9.18~dfsg~0-0ubuntu2.7) ...
dpkg-deb (subprocess): decompressing archive member: lzma error: compressed data is corrupt
dpkg-deb: error: subprocess <decompress> returned error exit status 2
dpkg: error processing archive /var/cache/apt/archives    /libgs9_9.18~dfsg~0-0ubuntu2.7_amd64.deb (--unpack):
 cannot copy extracted data for './usr/lib/x86_64-linux-gnu/libgs.so.9.18' to '/usr/lib/x86_64-linux-gnu/libgs.so.9.18.dpkg-new': unexpected end of file or stream
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Errors were encountered while processing:
 /var/cache/apt/archives/libgs9_9.18~dfsg~0-0ubuntu2.7_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我想尝试其他问题的建议,但它们都以类似的方式结束:

Errors were encountered while processing:
 libnspr4
 libnspr4:i386

随后会建议删除这些软件包,但我的错误不是软件包名称,而是 .deb 文件。我对 Ubuntu 还比较陌生,我可以通过浏览此处解决所有其他问题,但这个问题我无法解决。

根据乔治的建议进行编辑:

我运行了第一个命令

emiel@server:~$ sudo dpkg --configure -a
Setting up libgs9-common (9.18~dfsg~0-0ubuntu2.7) ...
Setting up linux-image-4.4.0-96-generic (4.4.0-96.119) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-96-generic
Found initrd image: /boot/initrd.img-4.4.0-96-generic
Found linux image: /boot/vmlinuz-4.4.0-92-generic
Found initrd image: /boot/initrd.img-4.4.0-92-generic
Found linux image: /boot/vmlinuz-4.4.0-91-generic
Found initrd image: /boot/initrd.img-4.4.0-91-generic
Found linux image: /boot/vmlinuz-4.4.0-89-generic
Found initrd image: /boot/initrd.img-4.4.0-89-generic
Found linux image: /boot/vmlinuz-4.4.0-87-generic
Found initrd image: /boot/initrd.img-4.4.0-87-generic
Found linux image: /boot/vmlinuz-4.4.0-83-generic
Found initrd image: /boot/initrd.img-4.4.0-83-generic
Found linux image: /boot/vmlinuz-4.4.0-81-generic
Found initrd image: /boot/initrd.img-4.4.0-81-generic
Found linux image: /boot/vmlinuz-4.4.0-70-generic
Found initrd image: /boot/initrd.img-4.4.0-70-generic
Adding boot menu entry for EFI firmware configuration
done
Setting up libisc-export160 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up bluez-cups (5.37-0ubuntu5.1) ...
Setting up linux-signed-image-4.4.0-96-generic (4.4.0-96.119) ...
warning: file-aligned section .text extends beyond end of file
warning: checksum areas are greater than image size. Invalid section table?
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-96-generic
Found initrd image: /boot/initrd.img-4.4.0-96-generic
Found linux image: /boot/vmlinuz-4.4.0-92-generic
Found initrd image: /boot/initrd.img-4.4.0-92-generic
Found linux image: /boot/vmlinuz-4.4.0-91-generic
Found initrd image: /boot/initrd.img-4.4.0-91-generic
Found linux image: /boot/vmlinuz-4.4.0-89-generic
Found initrd image: /boot/initrd.img-4.4.0-89-generic
Found linux image: /boot/vmlinuz-4.4.0-87-generic
Found initrd image: /boot/initrd.img-4.4.0-87-generic
Found linux image: /boot/vmlinuz-4.4.0-83-generic
Found initrd image: /boot/initrd.img-4.4.0-83-generic
Found linux image: /boot/vmlinuz-4.4.0-81-generic
Found initrd image: /boot/initrd.img-4.4.0-81-generic
Found linux image: /boot/vmlinuz-4.4.0-70-generic
Found initrd image: /boot/initrd.img-4.4.0-70-generic
Adding boot menu entry for EFI firmware configuration
done
Setting up libbluetooth3:amd64 (5.37-0ubuntu5.1) ...
Setting up linux-libc-dev:amd64 (4.4.0-96.119) ...
Setting up libdns-export162 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up libgd3:amd64 (2.1.1-4ubuntu0.16.04.8) ...
Setting up libgdk-pixbuf2.0-common (2.32.2-1ubuntu1.3) ...
Setting up linux-headers-4.4.0-96 (4.4.0-96.119) ...
Setting up linux-headers-4.4.0-96-generic (4.4.0-96.119) ...
dpkg: dependency problems prevent configuration of ghostscript:
 ghostscript depends on libgs9 (= 9.18~dfsg~0-0ubuntu2.7); however:
  Package libgs9:amd64 is not installed.

dpkg: error processing package ghostscript (--configure):
 dependency problems - leaving unconfigured
Setting up libxml2:amd64 (2.9.3+dfsg1-1ubuntu0.3) ...
Setting up tcpdump (4.9.2-0ubuntu0.16.04.1) ...
Installing new version of config file /etc/apparmor.d/usr.sbin.tcpdump ...
Setting up liblouis-data (2.6.4-2ubuntu0.1) ...
Setting up bluez-obexd (5.37-0ubuntu5.1) ...
Setting up liblwres141:amd64 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up linux-image-extra-4.4.0-96-generic (4.4.0-96.119) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-96-generic /boot/vmlinuz-4.4.0-96-generic
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-96-generic
Found initrd image: /boot/initrd.img-4.4.0-96-generic
Found linux image: /boot/vmlinuz-4.4.0-92-generic
Found initrd image: /boot/initrd.img-4.4.0-92-generic
Found linux image: /boot/vmlinuz-4.4.0-91-generic
Found initrd image: /boot/initrd.img-4.4.0-91-generic
Found linux image: /boot/vmlinuz-4.4.0-89-generic
Found initrd image: /boot/initrd.img-4.4.0-89-generic
Found linux image: /boot/vmlinuz-4.4.0-87-generic
Found initrd image: /boot/initrd.img-4.4.0-87-generic
Found linux image: /boot/vmlinuz-4.4.0-83-generic
Found initrd image: /boot/initrd.img-4.4.0-83-generic
Found linux image: /boot/vmlinuz-4.4.0-81-generic
Found initrd image: /boot/initrd.img-4.4.0-81-generic
Found linux image: /boot/vmlinuz-4.4.0-70-generic
Found initrd image: /boot/initrd.img-4.4.0-70-generic
Adding boot menu entry for EFI firmware configuration
done
dpkg: dependency problems prevent configuration of ghostscript-x:
 ghostscript-x depends on ghostscript (= 9.18~dfsg~0-0ubuntu2.7); however:
  Package ghostscript is not configured yet.

dpkg: error processing package ghostscript-x (--configure):
 dependency problems - leaving unconfigured
Setting up bluez (5.37-0ubuntu5.1) ...
Setting up linux-image-generic (4.4.0.96.101) ...
Setting up python3-jwt (1.3.0-1ubuntu0.1) ...
Setting up linux-headers-generic (4.4.0.96.101) ...
Setting up libisc160:amd64 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up linux-signed-image-generic (4.4.0.96.101) ...
Setting up libgdk-pixbuf2.0-0:amd64 (2.32.2-1ubuntu1.3) ...
Setting up gir1.2-gdkpixbuf-2.0:amd64 (2.32.2-1ubuntu1.3) ...
Setting up liblouis9:amd64 (2.6.4-2ubuntu0.1) ...
Setting up thunderbird (1:52.3.0+build1-0ubuntu0.16.04.1) ...
Processing triggers for bamfdaemon (0.5.3~bzr0+16.04.20160824-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Setting up libisccc140:amd64 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up thunderbird-gnome-support (1:52.3.0+build1-0ubuntu0.16.04.1) ...
Setting up linux-generic (4.4.0.96.101) ...
Setting up python3-louis (2.6.4-2ubuntu0.1) ...
Setting up libdns162:amd64 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up linux-signed-generic (4.4.0.96.101) ...
Setting up libisccfg140:amd64 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up thunderbird-locale-en (1:52.3.0+build1-0ubuntu0.16.04.1) ...
Setting up thunderbird-locale-en-us (1:52.3.0+build1-0ubuntu0.16.04.1) ...
Setting up libbind9-140:amd64 (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up bind9-host (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Setting up dnsutils (1:9.10.3.dfsg.P4-8ubuntu1.8) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Errors were encountered while processing:
 ghostscript
 ghostscript-x

之后我运行了更新:

emiel@server:~$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://nl.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://nl.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://nl.archive.ubuntu.com/ubuntu xenial-backports InRelease                      
Hit:5 http://shell.ninthgate.se/packages/debian jessie InRelease
Fetched 102 kB in 2s (48,2 kB/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
173 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Packages (main/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list.d/plex.list:1 and /etc/apt/sources.list.d/plex.list:2

此后我再次尝试,但出现与上述相同的错误。

我确实注释掉了文件 /etc/apt/sources.list.d/plex.list 中的第 2 行。此后,“更新”按预期工作。

emiel@server:~$ sudo apt update
Hit:1 http://nl.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:3 http://nl.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://nl.archive.ubuntu.com/ubuntu xenial-backports InRelease                                                
Hit:5 http://shell.ninthgate.se/packages/debian jessie InRelease
Fetched 102 kB in 1s (51,6 kB/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
173 packages can be upgraded. Run 'apt list --upgradable' to see them.

但不幸的是,“install -f”仍然会给我同样的消息。

所以我删除了 Debian 存储库并进行了更新,运行正常。之后我再次尝试配置:

emiel@server:/etc/apt/sources.list.d$ sudo dpkg --configure -a
dpkg: dependency problems prevent configuration of ghostscript:
 ghostscript depends on libgs9 (= 9.18~dfsg~0-0ubuntu2.7); however:
  Package libgs9:amd64 is not installed.

dpkg: error processing package ghostscript (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ghostscript-x:
 ghostscript-x depends on ghostscript (= 9.18~dfsg~0-0ubuntu2.7); however:
  Package ghostscript is not configured yet.

dpkg: error processing package ghostscript-x (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 ghostscript
 ghostscript-x

尝试安装 -f 仍然出现同样的错误。

谨致问候,埃米尔

答案1

对于遇到此问题的其他人,我是这样解决的:

问题是,当我尝试重新安装缺少的依赖项“libgs9”时,它会使用已存在于我服务器上的损坏的 .deb 文件。为了解决(删除)这个问题,我运行了

emiel@server:~$ sudo apt-get clean

这将删除损坏的 .deb 文件。之后,我运行了建议的命令,重新安装了“libgs9”。

emiel@server:~$ sudo apt-get install -f

我希望它也能解决您的问题!

非常感谢 George 和 Doug 帮助我找到了解决这个问题的方法。

埃米尔

相关内容