无法使用 aptitude 和 apt-get 在 Ubuntu 16.04 LTS 上安装 python-dev

无法使用 aptitude 和 apt-get 在 Ubuntu 16.04 LTS 上安装 python-dev

我正在尝试在 Windows 主机上运行的 Ubuntu 16.04 LTS(64 位)客户机上安装 python-dev。我尝试使用 apt-get 进行安装,然后通过 aptitude 进行安装,但似乎遇到了错误。

~$sudo aptitude install python-dev

给出,

The following NEW packages will be installed:
  libexpat1-dev{ab} libpython-dev{a} libpython2.7-dev{ab} python-dev python2.7-dev{ab} 
0 packages upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.2 MB of archives. After unpacking 42.1 MB will be used.
The following packages have unmet dependencies:
 python2.7-dev : Depends: python2.7 (= 2.7.11-7ubuntu1) but 2.7.12-1~16.04 is installed.
                 Depends: libpython2.7 (= 2.7.11-7ubuntu1) but 2.7.12-1~16.04 is installed.
 libexpat1-dev : Depends: libexpat1 (= 2.1.0-7) but 2.1.0-7ubuntu0.16.04.2 is installed.
 libpython2.7-dev : Depends: libpython2.7-stdlib (= 2.7.11-7ubuntu1) but 2.7.12-1~16.04 is installed.
                    Depends: libpython2.7 (= 2.7.11-7ubuntu1) but 2.7.12-1~16.04 is installed.
open: 20; closed: 1293; defer: 6; conflict: 6                                                                  o
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libexpat1-dev [Not Installed]                      
2)     libpython-dev [Not Installed]                      
3)     libpython2.7-dev [Not Installed]                   
4)     python-dev [Not Installed]                         
5)     python2.7-dev [Not Installed]                      



Accept this solution? [Y/n/q/?] 

作为输出。然而,

~$sudo apt-get install python-dev

给出,

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:
 python-dev : Depends: libpython-dev (= 2.7.11-1) but it is not going to be installed
              Depends: python2.7-dev (>= 2.7.11-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我运行了sudo aptitude updatesudo aptitude upgrade,但是这并不能解决问题。

此外,我还运行了以下链接中给出的步骤:

但似乎没有什么作用。

根据 aptitude 的消息,我认为我的系统上安装的依赖项的版本高于软件包所需的版本(例如,一条消息说Depends: libpython2.7 (= 2.7.11-7ubuntu1) but 2.7.12-1~16.04 is installed.)。

我猜我的选择是,

  • 卸载现有的软件包(我不想这样做),或者
  • 为 Python-stuff 添加更新的 PPA。

我当前的存储库是:

~$egrep -v '^#|^ *$' /etc/apt/sources.list /etc/apt/sources.list.d/*
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse

关于如何安装 python-dev 有什么想法吗?

提前致谢!

答案1

我的一个全新安装中有这些存储库。您似乎缺少一些update存储库。

*为在您的列表中没有看到的那些标记了星号。

apollo@apollo:~$ egrep -v '^#|^ *$' /etc/apt/sources.list /etc/apt/sources.list.d/*
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
* /etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
* /etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
/etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
* /etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
* /etc/apt/sources.list:deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
* /etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu xenial-security main restricted
* /etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu xenial-security universe
* /etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu xenial-security multiverse
grep: /etc/apt/sources.list.d/*: No such file or directory
apollo@apollo:~$ 

至少尝试添加update存储库...然后运行:

$ sudo apt update
$ sudo apt upgrade

答案2

在 aptitude 问题中输入“n”将使其提供另一种解决方案 - 降级一些软件包。它对我有用!

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

Downgrade the following packages:                                  
1)     libexpat1 [2.1.0-4ubuntu1.3 (now) -> 2.1.0-4ubuntu1 (trusty)]    
2)     libpython2.7 [2.7.6-8ubuntu0.3 (now) -> 2.7.6-8 (trusty)]        
3)     libpython2.7-minimal [2.7.6-8ubuntu0.3 (now) -> 2.7.6-8 (trusty)]
4)     libpython2.7-stdlib [2.7.6-8ubuntu0.3 (now) -> 2.7.6-8 (trusty)] 
5)     python2.7 [2.7.6-8ubuntu0.3 (now) -> 2.7.6-8 (trusty)]           
6)     python2.7-minimal [2.7.6-8ubuntu0.3 (now) -> 2.7.6-8 (trusty)]   

Accept this solution? [Y/n/q/?] y

相关内容