pip升级到10.0.1之后可能会出现这个错误。
环境:
pip version : 10.0.1
python version : 3.6.4
mac os : 10.12.6
错误出现路径还原:
升级pip
$python -m pip install pip --upgrade
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages (10.0.1)
升级后使用pip,报错
$pip -V
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2332, in resolve
return functools.reduce(getattr, self.attrs, module)
AttributeError: module 'pip' has no attribute 'main'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/python/libexec/bin/pip", line 11, in
load_entry_point('pip==9.0.3', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2693, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2334, in resolve
raise ImportError(str(exc))
ImportError: module 'pip' has no attribute 'main'
python3 -m pip install --user --upgrade pip==9.0.3
没有亲测这种方式,应该是可以的。
$curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$python get-pip.py
其中,如果是python3对应的pip3,则需要使用python3
,如下:
$python3 get-pip.py
更新完毕,便可使用pip或者pip3
$pip -V
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
$pip3 -V
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
brew reinstall python3