在升级到OS X Mavericks之后破坏了easy_install和pip

时间:2014-01-16 01:18:35

标签: python pip osx-mavericks setuptools easy-install

升级到OS X 10.9 Mavericks并安装了XCode,命令行工具,XQuartz等。现在尝试运行pip安装,但是它说没有找到分发:

Traceback (most recent call last):

  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File     "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py",     line 2603, in <module>
    working_set.require(__requires__)
  File   "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py",     line 666, in require
needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.4.1

所以我尝试用easy_install安装pip。事实证明,这也是不可能的:

Traceback (most recent call last):
  File "/usr/local/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2607, in <module>
parse_requirements(__requires__), Environment()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==1.1.6

所以其他一些线程说要用sudo python ez_setup.py重新安装setuptools。它似乎工作正常:

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg
Processing dependencies for setuptools==1.1.6
Finished processing dependencies for setuptools==1.1.6

但是当运行easy_install pip时,会发生相同的pkg_resources.DistributionNotFound:setuptools == 1.1.6错误。其他人有这个问题吗?任何想法如何解决这个问题?

3 个答案:

答案 0 :(得分:29)

  1. 安装easy_install

    https://pypi.python.org/pypi/setuptools

    下载ez_setup.py模块
    $ cd path/to/ez_setup.py
    $ python ez_setup.py
    
  2. 安装pip

    $ sudo easy_install pip
    

答案 1 :(得分:6)

尝试sudo python -m easy_install pip

答案 2 :(得分:4)

我遇到了与git-review类似的问题。

$ git review -s
Traceback (most recent call last):
  File "/usr/local/bin/git-review", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/git_review/cmd.py", line 1132, in main
    (os.path.split(sys.argv[0])[-1], get_version()))
  File "/Library/Python/2.7/site-packages/git_review/cmd.py", line 180, in get_version
    provider = pkg_resources.get_provider(requirement)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 197, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: git-review

The git-review team said it was a bug with pkg_resources可以用

修复
sudo pip install --upgrade setuptools

这对我来说很好。