解决:Ubuntu16.04安装python对应版本的pip和依赖包出错的问题

执行:sudo apt-get install python-pip python-dev

报错如下:

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.
 

解决方法:使用aptitude 工具

sudo apt-get install aptitude 

然后:sudo aptitude install python-dev

The following NEW packages will be installed:
  libpython-dev{a} libpython2.7-dev{ab} python-dev python2.7-dev{ab}

。。。 

4)     python2.7-dev [Not Installed]                      

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

     Downgrade the following packages:                                          
1)     libpython2.7 [2.7.12-1ubuntu0~16.04.2 (now) -> 2.7.11-7ubuntu1 (xenial)] 
2)     libpython2.7-minimal [2.7.12-1ubuntu0~16.04.2 (now) -> 2.7.11-7ubuntu1 (x
3)     libpython2.7-stdlib [2.7.12-1ubuntu0~16.04.2 (now) -> 2.7.11-7ubuntu1 (xe
4)     python2.7 [2.7.12-1ubuntu0~16.04.2 (now) -> 2.7.11-7ubuntu1 (xenial)]    
5)     python2.7-minimal [2.7.12-1ubuntu0~16.04.2 (now) -> 2.7.11-7ubuntu1 (xeni

Accept this solution? [Y/n/q/?] y
The following packages will be DOWNGRADED:
  libpython2.7 libpython2.7-minimal libpython2.7-stdlib python2.7 
。。。
Do you want to continue? [Y/n/?] y
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/precise-updates.list:1 and /etc/apt/sources.list.d/precise-updates.list:2
。。。
Setting up python2.7-dev (2.7.11-7ubuntu1) ...
Setting up python-dev (2.7.11-1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...

搞定了,可以执行sudo apt-get install python-pip python-dev了

发布了25 篇原创文章 · 获赞 28 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/maitianpt/article/details/88363945