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 中没
基础教程推荐
- matplotlib 设置 yaxis 标签大小 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
