1. 程式人生 > >python-pip python-dev build-essential無法安裝E: Unable to correct problems, you have held broken package

python-pip python-dev build-essential無法安裝E: Unable to correct problems, you have held broken package

用apt-get安裝python-dev老是報錯,缺少依賴包,報錯資訊:

The following packages have unmet dependencies:
 build-essential : Depends: dpkg-dev (>= 1.13.5) but it is not going to be installed
 python-dev : Depends: python (= 2.7.9-1) but 2.7.11-1 is to be installed
              Depends: libpython-dev (= 2.7.9-1) but it is not going to be installed
              Depends: python2.7-dev (>= 2.7.9-1~) but it is not going to be installed
 python-pip : Depends: python-setuptools (>= 0.6c1) but it is not going to be installed
              Recommends: python-dev-all (>= 2.6) but it is not installable
E: Unable to correct problems, you have held broken packages.

第一種方法:

將破損的包刪除掉,再執行安裝

sudo apt-get remove  dpkg-dev python libpython-dev python2.7-dev python-setuptools python-dev-all

第二種解決辦法:

我使用了一下aptitude去安裝
aptitude與 apt-get 一樣,是 Debian 及其衍生系統中功能極其強大的包管理工具。與 apt-get 不同的是,aptitude在處理依賴問題上更佳一些。舉例來說,aptitude在刪除一個包時,會同時刪除本身所依賴的包。這樣,系統中不會殘留無用的包,整個系統更為乾淨

首先先安裝aptitude

sudo apt-get install aptitude 

然後安裝你要的東西

sudo aptitude install xxxx