Pip 安装错误 Ubuntu 16.04

Pip 安装错误 Ubuntu 16.04

我目前正在使用 Ubuntu 16.04 和 Python 2.7。

尝试安装 pip 后出现以下错误

~$ sudo apt-get install python-pip
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-pip : Depends: python:any (< 2.8)
          Depends: python:any (>= 2.7.5-5~)
          Recommends: python-all-dev (>= 2.6) but it is not going to 
be installed
          Recommends: python-setuptools but it is not going to be 
installed
          Recommends: python-wheel but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我通过运行确保所有内容都已更新

sudo apt update && sudo apt upgrade --yes

我还获取了 curl 和 aptitude,并以各自的方法运行它们来安装 pip。最后,我卸载了 Python 并重新安装。但都无济于事。有什么解决办法吗?

答案1

看来您没有安装正确版本的 Python。您可能需要 2.7 版本的 pip。

sudo apt-get install python-minimal

这应该会给你推荐的版本。但如果版本高于 2.76,请执行以下操作:

wget  https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz  
./configure
make
make install

然后我还会安装 build-essential。

sudo apt-get install build-essential

然后切换 python 版本

sudo update-alternatives --config python

安装 pip 后

sudo apt-get install python-pip

相关内容