AttributeError: #39;module#39; object has no attribute #39;PROTOCOL_TLSv1_2#39; with Python 2.7.11(AttributeError: module 对象在 Python 2.7.11 中没有属性 PROTOCOL_TLSv1_2)
问题描述
我在为 Mac 上的 python 安装获取 tls v1.2 支持时遇到问题.
这是我的 openssl 版本:
openssl 版本OpenSSL 1.0.2h 2016 年 5 月 3 日这是我的python版本:
python --version蟒蛇 2.7.11
这是我的测试方式:
<预><代码>>>>导入 ssl>>>ssl.PROTOCOL_TLSv1_2回溯(最近一次调用最后一次):文件<stdin>",第 1 行,在 <module> 中AttributeError: 'module' 对象没有属性 'PROTOCOL_TLSv1_2'
阅读:https://docs.python.org/2/library/ssl.html它说:
<块引用>某些行为可能取决于平台,因为调用是对操作系统套接字 API.已安装的 OpenSSL 版本可能也会导致行为的变化.例如,TLSv1.1 和 TLSv1.2附带 openssl 版本 1.0.1.
所以我的 OpenSSL 1.0.2h 安装要求支持 tlsv1.2.
有人有什么想法吗?
问题是python使用的openssl版本不支持TLS 1.2.
我用 brew 安装了 openssl,然后重新安装了 python,告诉它使用我用 brew 安装的 openssl:
$ brew 更新$ brew install openssl$ brew install python --with-brewed-openssl
然后一切正常!
I am having issues getting tls v1.2 support for my python installation on my mac.
This is my openssl version:
openssl version
OpenSSL 1.0.2h 3 May 2016
And here is my python version:
python --version
Python 2.7.11
This is how I am testing:
>>> import ssl
>>> ssl.PROTOCOL_TLSv1_2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'
Reading this: https://docs.python.org/2/library/ssl.html It says:
Some behavior may be platform dependent, since calls are made to the operating system socket APIs. The installed version of OpenSSL may also cause variations in behavior. For example, TLSv1.1 and TLSv1.2 come with openssl version 1.0.1.
So I have the requirements for tlsv1.2 support with my installation of OpenSSL 1.0.2h.
Anyone have any ideas?
The problem was that the openssl version python was using did not support TLS 1.2.
I installed openssl with brew and then reinstalled python telling it to use the openssl i installed with brew:
$ brew update
$ brew install openssl
$ brew install python --with-brewed-openssl
Then everything worked!
这篇关于AttributeError: 'module' 对象在 Python 2.7.11 中没有属性 'PROTOCOL_TLSv1_2'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:AttributeError: 'module' 对象在 Python 2.7.11 中没


- 我如何卸载 PyTorch? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01