无法在 Ubuntu 12.04.2 LTS 上安装 python2.7-dev

无法在 Ubuntu 12.04.2 LTS 上安装 python2.7-dev

该命令$ sudo apt-get install python2.7-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:
 python2.7-dev : Depends: libexpat1-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

在运行安装命令之前,我已运行sudo apt-get updatesudo apt-get upgradesudo apt-get dist-upgrade尝试将存储库服务器从本地服务器(捷克共和国)切换到主服务器。我尝试使用 aptitude 安装软件包,结果是:

The following NEW packages will be installed:
  libexpat1-dev{ab} libssl-dev{a} libssl-doc{a} python2.7-dev 
0 packages upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 32.4 MB of archives. After unpacking 47.9 MB will be used.
The following packages have unmet dependencies:
 libexpat1-dev : Depends: libexpat1 (= 2.0.1-7.2ubuntu1.1) but 2.1.0-1ubuntu1 is installed.
The following actions will resolve these dependencies:

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



Accept this solution? [Y/n/q/?] Y
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

aptitude 建议的“解决方案”实际上不执行任何操作,也没有任何效果。打印出上述内容后,它存在,没有错误代码或任何错误消息。

我曾尝试删除 libexpat1,但是我需要的太多软件包都依赖于它,其中似乎包括大量的 gnome。

我尝试过的所有方法都没有任何效果,安装命令的结果仍然是一样的。

我在网上搜索了这个问题,发现了一些似乎与我的问题相关的帖子,但尽管它们可能被“解决”了,但却对我没有任何帮助(以下是我在问这个问题之前没有关闭的两个帖子):

  1. 由于未满足依赖关系,Ubuntu 12.04 无法安装 python2.7-dev
  2. https://askubuntu.com/questions/275861/problem-installing-python-dev

答案1

有趣的是:

libexpat1-dev : Depends: libexpat1 (= 2.0.1-7.2ubuntu1.1) but 2.1.0-1ubuntu1 is installed.

根据在线包裹搜索工具12.04 LTS两种版本libexpat12.0.1-7.2ubuntu1.1preciseprecise-updates。问题是,你2.1.0-1ubuntu1一开始是如何安装版本的?

使用aptitude()交互式用户界面,您可以搜索libexpat1,并选择适当的版本进行安装,即降级软件包以匹配libexpat1-dev依赖项。

您也可以从命令行执行此操作:

sudo aptitude install package=version

相关内容