Ubuntu 10.04中的Pip升级

时间:2014-02-02 21:45:16

标签: python ubuntu pip ubuntu-10.04

我按照安装指南http://www.pip-installer.org/en/latest/installing.htmlpip尝试在Ubuntu 10.04上升级sudo python get-pip.py(版本1.2.1)。

它似乎已升级:

/usr/local/lib/python2.6/dist-packages/setuptools/command/install_scripts.py:3: UserWarning: Module pip was already imported from /tmp/tmpZLKp_L/pip.zip/pip/__init__.py, but /usr/local/lib/python2.6/dist-packages/pip-1.2.1-py2.6.egg is being added to sys.path
  from pkg_resources import Distribution, PathMetadata, ensure_directory
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.2-py2.py3-none-any.whl#md5=445a893564065937c0f31ac2cc8e2f35
  Downloading pip-1.5.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.2.1
    Uninstalling pip:
      Successfully uninstalled pip
Successfully installed pip
Cleaning up...

但是当我输入pip时,我得到:

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.6/dist-packages/pkg_resources.py", line 2819, in <module>
    parse_requirements(__requires__), Environment()
  File "/usr/local/lib/python2.6/dist-packages/pkg_resources.py", line 588, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.2.1

不确定出了什么问题,我该如何解决?

1 个答案:

答案 0 :(得分:0)

升级pip时,它将旧版本(1.2.1)替换为版本1.5.2。但是看起来/usr/local/bin/pip的脚本仍在检查旧版本。这可能是由于使用apt安装原始文件然后通过单独的脚本进行升级而导致的冲突。这个答案提出了一个解决方案https://stackoverflow.com/a/6200314/66349(替换你自己的版本号):

I replaced 0.8.1 in 0.8.2 in /usr/local/bin/pip and everything worked again.

__requires__ = 'pip==0.8.2'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('pip==0.8.2', 'console_scripts', 'pip')()
    )