[英]AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
In python, on a Ubuntu server, I am trying to get the requests
library to make https requests, like so: 在python中,在Ubuntu服务器上,我试图让
requests
库发出https请求,如下所示:
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: A true SSLContext object is not available.
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90:InsecurePlatformWarning:真正的SSLContext对象不可用。 This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
这可以防止urllib3正确配置SSL,并可能导致某些SSL连接失败。 For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning .
有关更多信息,请参阅https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning 。
After following the advice in this question: InsecurePlatformWarning: A true SSLContext object is not available. 遵循此问题中的建议: InsecurePlatformWarning:真正的SSLContext对象不可用。 This prevents urllib3 from configuring SSL appropriately , I have now upgraded my warning to the following error:
这可以防止urllib3正确配置SSL ,我现在已将警告升级为以下错误:
AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'
AttributeError:'_socketobject'对象没有属性'set_tlsext_host_name'
How do I fix this? 我该如何解决?
The fix for me was the following: 我的修复方法如下:
sudo apt-get purge python-openssl
sudo pip install pyopenssl
This was able to get the python working on Ubuntu 12.04.3 LTS for me. 这让我能够在我的Ubuntu 12.04.3 LTS上运行python。
sudo apt-get install python-dev python-pip build-essential libffi-dev
sudo -H pip install --upgrade pip setuptools && sudo -H pip install --upgrade pyopenssl
On RedHat: 在RedHat上:
sudo yum remove pyOpenSSL
sudo pip install pyopenssl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.