Depends, python2.7-minimal (= 2.7.15_rc1-1) 问题解决方法使用 aptitude 安装以及与 apt-get 的区别

1. 问题现象

使用命令 sudo apt install python2.7 安装 Python2 时报如下错误

wohu@ubuntu1804:/etc/apt$ sudo apt install python2.7
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:
 python2.7 : Depends: python2.7-minimal (= 2.7.15~rc1-1) but it is not going to be installed
             Depends: libpython2.7-stdlib (= 2.7.15~rc1-1) but 2.7.17-1~18.04ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.

2. 解决方案

2.1 安装 aptitude

sudo apt-get install aptitude 

2.2 使用 aptitude 安装 python2.7

sudo aptitude install python2.7

依次选择 n,y, y

wohu@ubuntu1804:/etc/apt$ sudo aptitude install python2.7

The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     python2.7 [Not Installed]                          
2)     python2.7-minimal [Not Installed]                  

     Leave the following dependencies unresolved:         
3)     python2.7-minimal recommends python2.7             


Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

     Downgrade the following packages:                                            
1)     libpython2.7 [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic)]        
2)     libpython2.7-minimal [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic)]
3)     libpython2.7-stdlib [2.7.17-1~18.04ubuntu1 (now) -> 2.7.15~rc1-1 (bionic)] 


Accept this solution? [Y/n/q/?] y
The following packages will be DOWNGRADED:
  libpython2.7 libpython2.7-minimal libpython2.7-stdlib 
The following NEW packages will be installed:
  python2.7 python2.7-minimal{a} 
0 packages upgraded, 2 newly installed, 3 downgraded, 0 to remove and 34 not upgraded.
Need to get 4,826 kB of archives. After unpacking 4,105 kB will be used.
Do you want to continue? [Y/n/?] y

3. aptitude 与 apt-get 的区别

aptitudeapt-get 一样,是 Debian 及其衍生系统中功能极其强大的包管理工具。与 apt-get 不同的是,aptitude 在处理依赖问题上更佳一些。

举例来说,aptitude 在删除一个包时,会同时删除本身所依赖的包。这样,系统中不会残留无用的包,整个系统更为干净。

有的问题 apt-get 解决不了,必须使用 aptitude 解决,有的问题,用 aptitude 解决不了,必须使用 apt-get

  • aptitude 解决得更好的地方: install, remove, reinstall(apt-get无此功能), show(apt-get无此功能), search(apt-get无此功能), hold(apt-get无此功能), unhold(apt-get无此功能),

  • apt-get 解决得更好的地方: source(aptitude无此功能), build-dep (低版本的aptitude没有build-dep功能)

  • apt-getaptitude 没什么区别的地方:update, upgrade (apt-get upgrade=aptitude safe-upgrade, apt-get dist-upgrade=aptitude full-upgrgade)

  • 11
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值