Python“pip install”因AttributeError而失败:“module”对象没有属性“SSL_ST_INIT”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45188413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python "pip install " is failing with AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
提问by May
$ sudo pip install --upgrade pyOpenSSL
$ sudo pip install --upgrade pyOpenSSL
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==8.1.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558,
in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line
2682, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line
2355, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line
2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/download.py", line 39, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/_vendor/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py",
line
54, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in
<module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in
<module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
I am unable to Uninstall " pip uninstall pyopenssl "
我无法卸载“ pip uninstall pyopenssl ”
Using pip gets me this error.
使用 pip 给我这个错误。
Thanks in advance.
提前致谢。
Additional Details:
额外细节:
I am using
我在用
Distributor ID: Ubuntu Description: Ubuntu 15.10 Release: 15.10 Codename: wily
发行商 ID:Ubuntu 描述:Ubuntu 15.10 版本:15.10 代号:wily
回答by delimiter
I ran into this issue as well. The solution proposed to run pip doesn't work because pip is broken too! I found this solved it for me:
我也遇到了这个问题。建议运行 pip 的解决方案不起作用,因为 pip 也坏了!我发现这为我解决了它:
sudo python -m easy_install --upgrade pyOpenSSL
This installed version 17.3.0 which was an upgrade to the (stock python-openssl on xenial) version ?0.15.1?. Note the massive change in version it could be they dropped the leading 0. in later versions.
这安装了 17.3.0 版,这是对(xenial 上的股票 python-openssl)版本 0.15.1 的升级。请注意版本的巨大变化,可能是他们在以后的版本中删除了前导 0.。
Anyway, after that, pip and ansible started to work again.
无论如何,在那之后,pip和ansible又开始工作了。
回答by Severun
I did the following which seemed to fix the error, not sure if it's the correct way, but it did fix the error on my machine:
我做了以下似乎修复了错误的操作,不确定它是否是正确的方法,但它确实修复了我机器上的错误:
I first backed up the directories below, recommend you do same.
我首先备份了以下目录,建议您也这样做。
rm -rf /usr/lib/python2.7/dist-packages/OpenSSL
rm -rf /usr/lib/python2.7/dist-packages/pyOpenSSL-0.15.1.egg-info
sudo pip install pyopenssl
I couldn't uninstall it because every time I ran pip I got the same error you did: 'module' object has no attribute 'SSL_ST_INIT'.
我无法卸载它,因为每次运行 pip 时都会遇到与您相同的错误:'module' object has no attribute 'SSL_ST_INIT'。
After the above my pip now works and more importantly my ansible now works (which was broken by my previous updates).
在上述之后,我的 pip 现在可以工作了,更重要的是我的 ansible 现在可以工作(这被我之前的更新破坏了)。
Not sure if it will work on your system, and removing things out of band, like I did, is risky at best, so as a warning, I would say, your mileage may vary with my kludgy fix, use caution!
不确定它是否适用于您的系统,并且像我一样删除带外内容充其量是有风险的,因此作为警告,我想说的是,您的里程可能会因我的笨拙修复而有所不同,请谨慎使用!
回答by Puneet Joshi
Upgrading pyOpenSSL to 16.2.0 fixes it.
将 pyOpenSSL 升级到 16.2.0 修复了它。
pip uninstall pyOpenSSL
pip install pyOpenSSL==16.2.0
There is an issue with version compatibility.
版本兼容性有问题。