Ubuntu

無法在 Ubuntu 12.04.2 LTS 上安裝 python2.7-dev

  • June 23, 2013

該命令$ 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 upgrade並且sudo 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

這裡有趣的一點是:

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

根據線上包搜尋工具12.04 LTSlibexpat12.0.1-7.2ubuntu1.1precise. precise-updates問題是,您最初是如何2.1.0-1ubuntu1安裝版本的?

使用aptitude()互動式 UI,您可以搜尋libexpat1並選擇合適的版本進行安裝,即降級軟體包以匹配libexpat1-dev依賴項。

您也可以從命令行執行此操作:

sudo aptitude install package=version

引用自:https://serverfault.com/questions/517875