无法升级 pip

无法升级 pip

我是 Linux 和 Ubuntu 的新手。

我试图升级 pip 但遇到了这个问题......

$ sudo pip install --upgrade pip
Cannot fetch index base URL https://pypi.python.org/simple/
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.1.0-py2.py3-none-any.whl#md5=b108384a762825ec20345bb9b5b7209f
  Downloading pip-7.1.0-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.5.4
    Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed pip
Cleaning up...

知道为什么吗?

答案1

尝试使用以下命令安装easy_install

easy_install -U pip

答案2

我很久以前就遇到过同样的问题,今天终于找到了解决方案。通过 python-pip 安装 pip 时,需要从已弃用的 Linux 服务器下载。您应该从 python 服务器下载。要解决此问题,请执行以下操作:

sudo apt-get purge pip
sudo apt-get install python-setuptools
sudo apt-get install python-dev 
sudo easy_install pip 
pip install pip --upgrade 

答案3

这是由于系统包(例如)提供的 pip 版本python-pip与 PyPI 通过 pip 本身提供的版本之间的冲突引起的。

要修复此问题,只需删除python-pip即可sudo apt-get purge python-pip

如果您已经使用旧版本的 pip 安装了较新版本,则更新后的版本应该保留在 中/usr/local/bin。如果没有,您可以使用以下命令从头开始安装最新版本的 Pip:

Python 2.7 的 Pip:

curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7

适用于 Python 3.x 的 Pip:

curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python3

答案4

实际上,您可以编辑“pip”脚本:

从根目录:

$ which pip  # -> prints 'pip' location

$ nano `which pip` # -> open with your editor, note the backticks!

用你最新的 pip 版本替换__requires__,例如:

__requires__ = 'pip==7.1.2'

然后编辑包含“load_entry_point”调用的行:

load_entry_point(__requires__, 'console_scripts', 'pip')()

和:

$pip -V
pip 7.1.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)

另外,我必须更新我的安装工具包,安装一些包。

相关内容