Ubuntu安装libssl-dev失败

2018年4月20日

最近打算用Python3写一个签名验证工具,安装pyOpenSSL时需要用到本机的libssl-dev库,进一步在Ubuntu上尝试安装库时出错,如下:

  1. ygu@guyongqiangx:~$ sudo apt-get install libssl-dev
  2. Reading package lists... Done
  3. Building dependency tree
  4. Reading state information... Done
  5. Some packages could not be installed. This may mean that you have
  6. requested an impossible situation or if you are using the unstable
  7. distribution that some required packages have not yet been created
  8. or been moved out of Incoming.
  9. The following information may help to resolve the situation:
  10. The following packages have unmet dependencies:
  11. libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.19 is to be installed
  12. Recommends: libssl-doc but it is not going to be installed
  13. E: Unable to correct problems, you have held broken packages.

度娘搜索提示说建议使用aptitude进行安装

  1. ygu@guyongqiangx:~$ sudo apt-get install aptitude
  2. Reading package lists... Done
  3. Building dependency tree
  4. Reading state information... Done
  5. aptitude is already the newest version.
  6. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

发现我原来已经安装过aptitude了

使用aptitude再次安装libssl-dev,并选择降级的版本。

  1. ygu@guyongqiangx:~$ sudo aptitude install libssl-dev
  2. The following NEW packages will be installed:
  3. libssl-dev{b} libssl-doc{a}
  4. 0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
  5. Need to get 2,031 kB of archives. After unpacking 7,801 kB will be used.
  6. The following packages have unmet dependencies:
  7. libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2) but 1.0.1f-1ubuntu2.19 is installed.
  8. The following actions will resolve these dependencies:
  9. ###
  10. Keep the following packages at their current version:
  11. 1) libssl-dev [Not Installed]
  12. ###
  13. # 这里提示时,一定要选n,选Y跟apt-get install操作一样
  14. Accept this solution? [Y/n/q/?] n
  15. The following actions will resolve these dependencies:
  16. ###
  17. Downgrade the following packages:
  18. 1) libssl1.0.0 [1.0.1f-1ubuntu2.19 (now) -> 1.0.1f-1ubuntu2 (trusty)]
  19. ###
  20. # 接受这里的降级处理,成功安装
  21. ###
  22. Accept this solution? [Y/n/q/?] y
  23. The following packages will be DOWNGRADED:
  24. libssl1.0.0
  25. The following NEW packages will be installed:
  26. libssl-dev libssl-doc{a}
  27. 0 packages upgraded, 2 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
  28. Need to get 2,857 kB of archives. After unpacking 7,784 kB will be used.
  29. Do you want to continue? [Y/n/?] y
  30. Get: 1 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl1.0.0 amd64 1.0.1f-1ubuntu2 [825 kB]
  31. Get: 2 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl-doc all 1.0.1f-1ubuntu2 [965 kB]
  32. Get: 3 http://mirrors.aliyun.com/ubuntu/ trusty/main libssl-dev amd64 1.0.1f-1ubuntu2 [1,066 kB]
  33. Fetched 2,857 kB in 50s (57.1 kB/s)
  34. Preconfiguring packages ...
  35. dpkg: warning: downgrading libssl1.0.0:amd64 from 1.0.1f-1ubuntu2.19 to 1.0.1f-1ubuntu2
  36. (Reading database ... 234481 files and directories currently installed.)
  37. Preparing to unpack .../libssl1.0.0_1.0.1f-1ubuntu2_amd64.deb ...
  38. Unpacking libssl1.0.0:amd64 (1.0.1f-1ubuntu2) over (1.0.1f-1ubuntu2.19) ...
  39. Selecting previously unselected package libssl-dev:amd64.
  40. Preparing to unpack .../libssl-dev_1.0.1f-1ubuntu2_amd64.deb ...
  41. Unpacking libssl-dev:amd64 (1.0.1f-1ubuntu2) ...
  42. Selecting previously unselected package libssl-doc.
  43. Preparing to unpack .../libssl-doc_1.0.1f-1ubuntu2_all.deb ...
  44. Unpacking libssl-doc (1.0.1f-1ubuntu2) ...
  45. Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
  46. Setting up libssl1.0.0:amd64 (1.0.1f-1ubuntu2) ...
  47. Setting up libssl-dev:amd64 (1.0.1f-1ubuntu2) ...
  48. Setting up libssl-doc (1.0.1f-1ubuntu2) ...
  49. Processing triggers for libc-bin (2.19-0ubuntu6.9) ...

安装成功。

简单总结:

apt-get安装时会默认选择预设的依赖版本。
aptitude安装时会提示是否选择默认设定的依赖版本,如果选n,会对库进行依赖降级,从而安装期望的版本。

没有评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注