我的笔记本电脑中有最新版本的 pip。当我使用 pip 安装任何模块时总是会出现此错误。
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-
packages/pkg_resources/__init__.py", line 3195, in <module>
@_call_aside
File "/usr/local/lib/python2.7/site-
packages/pkg_resources/__init__.py", line 3179, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/site-p
packages/pkg_resources/__init__.py", line 3208, in _
initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/site-
packages/pkg_resources/__init__.py", line 681, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python2.7/site-
packages/pkg_resources/__init__.py", line 999, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python2.7/site-
packages/pkg_resources/__init__.py", line 885, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==9.0.3' distribution was not found and is required by the application
我该如何解决这个错误。
答案1
您的 pip 很可能由于缺少依赖项而崩溃。尝试重新安装 pip。
sudo easy_install pip==9.0.3
答案2
我遇到了和你一样的问题。但经过 3 小时的互联网搜索,我找到了解决方案。使用
python-m pip 复制代码
运行 pip 的命令。
当你想安装新模块时,
python -m pip install "模块名称"
这将解决你的问题!!
答案3
看起来你正在使用 Homebrew。如果是这样,对我有用的是运行brew reinstall python
。这带来了 pip 的干净副本。