MacOS 上的 PIP 错误

MacOS 上的 PIP 错误

我尝试在 Mac 上使用 PIP,但无法使用。缺少什么?如何修复?

pip --version
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/__init__.py", line 3095, in <module>
    @_call_aside
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3081, in _call_aside
    f(*args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3108, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 658, in _build_master
    ws.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 959, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 846, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==18.1' distribution was not found and is required by the application

答案1

我建议你尝试pipenv,它是 pip 和 virtualenv 的薄包装器。它允许您创建独立的 pip 环境,这些环境不会相互干扰,也不会干扰全局 pip 配置。也许它可以帮助您绕过问题。

答案2

Python 的路径是否存在问题,是否有可能你已经删除了。

在这种情况下使用这些命令:

brew --prefix /lib/python2.7/site-packages

pip install -U pip 

pip3 install --upgrade pip

brew install pipenv

相关内容