红联Linux门户
Linux帮助

Debian的修复pip AttributeError: 'module' object has no

发布时间:2016-10-12 09:31:36来源:linux网站作者:rainysia
升级到最新的stable后,Python的pip还是老的. 在安装一些包的时候,报错了:
Traceback (most recent call last):  
File "/usr/bin/pip", line 9, in <module>  
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()  
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point  
return get_distribution(dist).load_entry_point(group, name)  
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point  
return ep.load()  
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load  
['__name__'])  
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>  
from pip.vcs import git, mercurial, subversion, bazaar  # noqa  
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>  
from pip.download import path_to_url  
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>  
import requests, six  
File "/usr/local/lib/python2.7/dist-packages/requests-2.4.3-py2.7.egg/requests/__init__.py", line 53, in <module>  
from .packages.urllib3.contrib import pyopenssl  
File "/usr/local/lib/python2.7/dist-packages/requests-2.4.3-py2.7.egg/requests/packages/urllib3/contrib/pyopenssl.py", line 73, in <module>  
ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD,  
AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'  
 
原因是debian8的pip用了urllib3, 而urllib3使用了debian8的新编译的OpenSSL SSLv3版. 
 
修复很简单, 升级pip.
pip install requests==2.6.0  
或者
easy_install --upgrade pip
然后就可以pip install 安装了。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/24944.html