AttributeError:'_socketobject'对象没有属性'set_tlsext_host_name' [英] AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
问题描述
在python中,在Ubuntu服务器上,我试图获取 requests
库来发出https请求,如下所示:
In python, on a Ubuntu server, I am trying to get the requests
library to make https requests, like so:
import requests
requests.post("https://example.com")
首先,我得到以下信息:
At first, I got the following:
/ usr / local / lib / python2.7 / dist-packages / requests / packages / urllib3 / util / ssl_.py:90:
InsecurePlatformWarning:真正的SSLContext对象不可用。
这可以防止urllib3正确配置SSL,并可能导致
某些SSL连接失败。有关详细信息,请参阅
https://urllib3.readthedocs.org /en/latest/security.html#insecureplatformwarning 。
按照此问题中的建议后:InsecurePlatformWarning:真正的SSLContext对象不可用。这可以防止urllib3正确配置SSL ,我现在已将警告升级为以下错误:
After following the advice in this question: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately, I have now upgraded my warning to the following error:
AttributeError:'_socketobject'对象没有属性
'set_tlsext_host_name'
AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
如何解决此问题?
推荐答案
我的修复方法如下:
sudo apt-get purge python-openssl
sudo pip install pyopenssl
这篇关于AttributeError:'_socketobject'对象没有属性'set_tlsext_host_name'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!