安装 zlib1g-dev 时出错

ksl*_*ksl 3 apt zlib 16.04

我是 Ubuntu 新手,想在 Ubuntu 16.04.3 LTS 上安装 zlib1g-dev。

命令:

sudo apt-get install zlib1g-dev
Run Code Online (Sandbox Code Playgroud)

导致以下错误:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies.
 zlib1g-dev : Depends: zlib1g (= 1:1.2.8.dfsg-2ubuntu4) but 1:1.2.8.dfsg-2ubuntu4.1 is to be installed
E: Unable to correct problems, you have held broken packages.
Run Code Online (Sandbox Code Playgroud)

我一直在四处寻找,但我不知道如何解决这个问题。

更多信息:

sudo apt-get -f install && sudo dpkg --configure -a
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.


apt-cache policy build-essential libc6-dev libc-dev g++ libpcap-dev libpcap0.8-dev libpq-dev krb5-multidev comerr-dev libsqlite3-dev postgresql postgresql-9.3 zlib1g-dev
build-essential:
  Installed: 12.1ubuntu2
  Candidate: 12.1ubuntu2
  Version table:
 *** 12.1ubuntu2 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
libc6-dev:
  Installed: 2.23-0ubuntu9
  Candidate: 2.23-0ubuntu9
  Version table:
 *** 2.23-0ubuntu9 100
        100 /var/lib/dpkg/status
     2.23-0ubuntu3 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libc-dev:
  Installed: (none)
  Candidate: (none)
  Version table:
g++:
  Installed: 4:5.3.1-1ubuntu1
  Candidate: 4:5.3.1-1ubuntu1
  Version table:
 *** 4:5.3.1-1ubuntu1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
libpcap-dev:
  Installed: (none)
  Candidate: 1.7.4-2
  Version table:
     1.7.4-2 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main i386 Packages
libpcap0.8-dev:
  Installed: (none)
  Candidate: 1.7.4-2
  Version table:
     1.7.4-2 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libpq-dev:
  Installed: (none)
  Candidate: 9.5.2-1
  Version table:
     9.5.2-1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
krb5-multidev:
  Installed: (none)
  Candidate: 1.13.2+dfsg-5
  Version table:
     1.13.2+dfsg-5 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
comerr-dev:
  Installed: (none)
  Candidate: 2.1-1.42.13-1ubuntu1
  Version table:
     2.1-1.42.13-1ubuntu1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
libsqlite3-dev:
  Installed: (none)
  Candidate: 3.11.0-1ubuntu1
  Version table:
     3.11.0-1ubuntu1 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
postgresql:
  Installed: (none)
  Candidate: 9.5+173
  Version table:
     9.5+173 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main i386 Packages
postgresql-9.3:
  Installed: (none)
  Candidate: (none)
  Version table:
zlib1g-dev:
  Installed: (none)
  Candidate: 1:1.2.8.dfsg-2ubuntu4
  Version table:
     1:1.2.8.dfsg-2ubuntu4 500
        500 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
Run Code Online (Sandbox Code Playgroud)

Sei*_*Sys 8

我只是在尝试安装一些用于编译 Ruby 的依赖项时遇到了同样的问题。

摆脱这种痛苦的最简单方法是在倒数第二行记下包和版本:zlib1g1:1.2.8.dfsg-2ubuntu4,然后发出以下命令:

$ sudo apt install zlib1g=1:1.2.8.dfsg-2ubuntu4
Run Code Online (Sandbox Code Playgroud)

这将降级zlib1g到所需的版本,之后安装应该会成功。