python - 在 macOS Sierra 上安装 pip

标签 python macos pip macos-sierra

我一直在尝试通过 brew 在 macOS sierra 上安装 pip,但每次它完成时都没有在 /usr/local/Cellar/python/2.7.13/bin 中安装二进制文件。

我试过了:

MacBook-Pro ➜ brew reinstall python

然后:

MacBook-Pro ➜  ~ which pip
pip not found

我找到了 python 的路径,即 /usr/local/Cellar/python/2.7.13/bin 但那里没有 pip 的二进制文件。

我也尝试了 easy_install 方法:

MacBook-Pro ➜ sudo easy_install pip
Traceback (most recent call last):
  File "/usr/bin/easy_install-2.7", line 11, in <module>
    load_entry_point('setuptools==18.5', 'console_scripts', 'easy_install')()
  File "/Library/Python/2.7/site-packages/pkg_resources.py", line 352, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2307, in load_entry_point
    return ep.load()
  File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2021, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/__init__.py", line 12, in <module>
    from setuptools.extension import Extension
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/extension.py", line 8, in <module>
    from .dist import _get_unpatched
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 21, in <module>
    packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'

更新:

当我运行 brew postinstall python 我收到以下错误:

MacBook-Pro ➜  ~ brew postinstall python
==> Using the sandbox
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --rec
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --rec
Last 15 lines from /Users/justin/Library/Logs/Homebrew/python/post_install.02.python:

Traceback (most recent call last):
  File "setup.py", line 92, in <module>
    cmdclass={'test': PyTest},
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
    _setup_distribution = dist = klass(attrs)
  File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.py", line 225, in __init__
    _Distribution.__init__(self,attrs)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
    self.finalize_options()
  File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.py", line 258, in finalize_options
    ep.load()(self, ep.name, value)
  File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2020, in load
    raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError: <module 'setuptools.dist' from '/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.pyc'> has no 'check_specifier' attribute

最佳答案

您只需要安装 macOS Sierra 中不会自动安装的 pip

运行 sudo easy_install pip

关于python - 在 macOS Sierra 上安装 pip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41233594/

相关文章:

python - 使用 BS4 将 HTML 表抓取为 CSV 以与 Pandas 一起使用

macos - curl 下载在 OS X Yosemite 上失败

.net - 关于 mono 和 coreclr 的混淆 ( OS X )

python - pip3.4 -V指的是python2.7的安装

python - Excel 的 Beta 分布的 Python 等价物是什么?

python - 应用Sklearn高斯混合算法拟合GM曲线

python - 使用 Python 从文本文件中读取的行中的结束行字符

objective-c - Cocoa 绑定(bind)到 NSTableView 选择

python - 数据科学体验上的 AssertionError : Multiple . dist-info 目录

python - 我无法安装 pyPDF 包 根本找不到 pyPdf 的发行版