python - 无法将 pip 从 1.5.4 升级到最新版本

标签 python ubuntu pip

我正在运行 ubuntu gnome 14.04,并为 python 2.7.6 和 python 3.4.3 安装了 pip 1.5.4。

我想将 pip 升级到最新版本,但是当我运行命令时 pip install -U pip 我收到以下错误。

Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB 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
  Can't roll back pip; was not uninstalled
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 672, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 902, in move_wheel_files
    pycompile=self.pycompile,
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 206, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 193, in clobber
    os.makedirs(destsubdir)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip'

Storing debug log for failure in /tmp/tmpDLrBk_

关于使用 sudo ,即;

sudo pip install -U pip

错误 -

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 58 not upgraded.
alzio@alzio-HP-Pavilion-Notebook:/$ sudo -H pip install --upgrade pip
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip in /usr/lib/python2.7/dist-packages
Downloading/unpacking pip
Cleaning up...
No distributions at all found for pip in /usr/lib/python2.7/dist-packages
Storing debug log for failure in /root/.pip/pip.log

最佳答案

我也遇到了同样的问题。我使用

备份了我的 pip 安装
sudo mv /usr/lib/python2.7/dist-packages/pip* .
sudo mv /usr/local/lib/python2.7/dist-packages/pip local_pip

然后我下载了一个引导脚本并执行它:

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

执行即可确认pip升级成功

pip -V

我从pypa获得了引导链接。我很感激反馈,因为我很确定这可以简化,但重置我的 pip 版本可能很棘手。

关于python - 无法将 pip 从 1.5.4 升级到最新版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42634650/

相关文章:

python - 网络爬虫 - TooManyRedirects : Exceeded 30 redirects. (python)

python-3.x - 全新安装 Python 3 时没有名为 'info' 的模块

python - 如何在 Anaconda (Conda) 环境中跟踪 pip 安装的软件包?

python - 如何在不使用 import * 的情况下导入导入其他模块的模块

python - 实现 wxpython 的 html2.WebViewHandler 和 html2.WebViewFSHandler 的问题

python - 从 Python 生成图形的最简单方法?

c# - 夏普在 ubuntu 中开发

Git - 如何验证 Git 是否安装在 Ubuntu 上以及安装在何处

ubuntu - 虚拟盒子的主机名和端口号

python - Conda 在尝试安装 biopython 后返回未找到的属性错误符号