
Ubuntu安装libssl-dev失败
本文记录了在 Ubuntu 上安装 libssl-dev 时遇到依赖冲突的解决方法,通过使用 aptitude 工具对依赖库进行降级处理,成功安装所需开发库。
安装pyOpenSSL时需要用到本机的libssl-dev库,进一步在Ubuntu上尝试安装库时出错,如下:
1jeromexiong@ubuntu:~$ sudo apt-get install libssl-dev
2Reading package lists... Done
3Building dependency tree
4Reading state information... Done
5Some packages could not be installed. This may mean that you have
6requested an impossible situation or if you are using the unstable
7distribution that some required packages have not yet been created
8or been moved out of Incoming.
9The following information may help to resolve the situation:
10
11The following packages have unmet dependencies:
12 libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.19 is to be installed
13 Recommends: libssl-doc but it is not going to be installed
14E: Unable to correct problems, you have held broken packages.
度娘搜索提示说建议使用aptitude进行安装
sudo apt-get install aptitude
使用aptitude再次安装libssl-dev,并选择降级的版本。
1jeromexiong@ubuntu:~$ sudo aptitude install libssl-dev
2The following NEW packages will be installed:
3 libssl-dev{b} libssl-doc{a}
40 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
5Need to get 2,031 kB of archives. After unpacking 7,801 kB will be used.
6The following packages have unmet dependencies:
7 libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.19 is installed.
8The following actions will resolve these dependencies:
9
10 Keep the following packages at their current version:
111) libssl-dev [Not Installed]
12
13
14# 这里提示时,一定要选n,选Y跟apt-get install操作一样
15Accept this solution? [Y/n/q/?] n
16The following actions will resolve these dependencies:
17
18 Downgrade the following packages:
191) libssl1.0.0 [1.0.1f-1ubuntu2.19 (now) -> 1.0.1f-1ubuntu2 (trusty)]
20
21
22# 接受这里的降级处理,成功安装
23Accept this solution? [Y/n/q/?] y
24The following packages will be DOWNGRADED:
25 libssl1.0.0
26The following NEW packages will be installed:
27 libssl-dev libssl-doc{a}
280 packages upgraded, 2 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
29Need to get 2,857 kB of archives. After unpacking 7,784 kB will be used.
30Do you want to continue? [Y/n/?] y
31Get: 1 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl1.0.0 amd64 1.0.1f-1ubuntu2 [825 kB]
32Get: 2 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl-doc all 1.0.1f-1ubuntu2 [965 kB]
33Get: 3 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl-dev amd64 1.0.1f-1ubuntu2 [1,066 kB]
34Fetched 2,857 kB in 50s (57.1 kB/s)
35Preconfiguring packages ...
36dpkg: warning: downgrading libssl1.0.0:amd64 from 1.0.1f-1ubuntu2.19 to 1.0.1f-1ubuntu2
37(Reading database ... 234481 files and directories currently installed.)
38Preparing to unpack .../libssl1.0.0_1.0.1f-1ubuntu2_amd64.deb ...
39Unpacking libssl1.0.0:amd64 (1.0.1f-1ubuntu2) over (1.0.1f-1ubuntu2.19) ...
40Selecting previously unselected package libssl-dev:amd64.
41Preparing to unpack .../libssl-dev_1.0.1f-1ubuntu2_amd64.deb ...
42Unpacking libssl-dev:amd64 (1.0.1f-1ubuntu2) ...
43Selecting previously unselected package libssl-doc.
44Preparing to unpack .../libssl-doc_1.0.1f-1ubuntu2_all.deb ...
45Unpacking libssl-doc (1.0.1f-1ubuntu2) ...
46Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
47Setting up libssl1.0.0:amd64 (1.0.1f-1ubuntu2) ...
48Setting up libssl-dev:amd64 (1.0.1f-1ubuntu2) ...
49Setting up libssl-doc (1.0.1f-1ubuntu2) ...
50Processing triggers for libc-bin (2.19-0ubuntu6.9) ...
安装成功。
简单总结:
- apt-get安装时会默认选择预设的依赖版本。
- aptitude安装时会提示是否选择默认设定的依赖版本,如果选n,会对库进行依赖降级,从而安装期望的版本。
- 标题: Ubuntu安装libssl-dev失败
- 作者: Jerome Xiong
- 创建于: 2020-03-15 18:00
- 链接: https://jeromexiong.github.io/2020/03/15/Linux-DevOps/Ubuntu安装libssl-dev失败/
- 版权声明:本文章采用 CC BY-NC-SA 4.0 进行许可。
评论