简体   繁体   English

AttributeError:'_socketobject'对象没有属性'set_tlsext_host_name'

[英]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.

相关问题 AttributeError: '_socketobject' 对象没有属性 'error' - AttributeError: '_socketobject' object has no attribute 'error' AttributeError:'_socketobject'对象没有属性'bind' - AttributeError: '_socketobject' object has no attribute 'bind' AttributeError:类型对象“ _socketobject”没有属性“ error” - AttributeError: type object '_socketobject' has no attribute 'error' Python Web套接字AttributeError:类型对象'_socketobject'没有属性'gethostbyname' - Python Web Socket AttributeError: type object '_socketobject' has no attribute 'gethostbyname' _socketobject'对象没有属性'bing' - _socketobject' object has no attribute 'bing' 套接字编程,attributeerror'_socketobject'对象属性'bind'是只读的 - Socket programming, attributeerror '_socketobject' object attribute 'bind' is read-only AttributeError: '***' 对象没有属性 '***_set' - AttributeError: '***' object has no attribute '***_set' AttributeError:“列表”对象没有属性“主机” - AttributeError: 'list' object has no attribute 'host' AttributeError:“ ...”对象没有属性“ *** _ set” - AttributeError: '…' object has no attribute '***_set' AttributeError: '...' object 没有属性 '_set' - AttributeError: '…' object has no attribute '_set'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM