AttributeError:“\u socketobject”对象没有“set-tlsext-u host-name”属性

2024-04-27 06:11:47 发布

您现在位置:Python中文网/ 问答频道 /正文

在python中,在Ubuntu服务器上,我试图让requests库发出https请求,如下所示:

import requests
requests.post("https://example.com")

首先,我得到了以下信息:

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.

在遵循此问题中的建议:InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately之后,我现在已将警告升级为以下错误:

AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'

我该怎么解决?


Tags: fromhttpstruesslobjectispackagesnot
3条回答

我的解决办法如下:

sudo apt-get purge python-openssl
sudo pip install pyopenssl

这使得python能够为我开发Ubuntu 12.04.3lts。

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

关于红帽:

sudo yum remove pyOpenSSL
sudo pip install pyopenssl

相关问题 更多 >