使用请求包时出现 SSL InsecurePlatform 错误 [英] SSL InsecurePlatform error when using Requests package
问题描述
我使用 Python 2.7.3 和请求.我通过 pip 安装了 Requests.我相信这是最新版本.我在 Debian Wheezy 上运行.
Im using Python 2.7.3 and Requests. I installed Requests via pip. I believe it's the latest version. I'm running on Debian Wheezy.
我过去曾多次使用 Requests 并且从未遇到过这个问题,但似乎在使用 Requests
发出 https 请求时,我收到了 InsecurePlatform
异常.
I've used Requests lots of times in the past and never faced this issue, but it seems that when making https requests with Requests
I get an InsecurePlatform
exception.
错误提到了 urllib3
,但我没有安装.我确实安装了它以检查它是否解决了错误,但没有解决.
The error mentions urllib3
, but I don't have that installed. I did install it to check if it resolved the error, but it didn't.
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3
/util/ssl_.py:79: 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.
关于为什么我得到这个的任何想法?我已按照错误消息中的说明检查了文档,但文档说要导入 urllib3 并禁用警告或提供证书.
Any ideas as to why I'm getting this? I've checked the docs, as specified in the error message, but the docs are saying to import urllib3 and either disable the warning, or provide a certificate.
推荐答案
使用有点隐藏的安全功能:
pip install requests[security]
或者pip install pyOpenSSL ndg-httpsclient pyasn1
这两个命令都会安装以下额外的包:
Both commands install following extra packages:
- pyOpenSSL
- 密码学
- idna
请注意,python-2.7.9+.
如果pip install
失败并出现错误,请检查您是否有libffi
、libssl
和python
所需的开发包> 安装在您的系统中使用分发包管理器:
If pip install
fails with errors, check whether you have required development packages for libffi
, libssl
and python
installed in your system using distribution's package manager:
Debian/Ubuntu -
python-dev
libffi-dev
libssl-dev
包.
Fedora - openssl-devel
python-devel
libffi-devel
包.
上面的发行版列表不完整.
解决方法(查看@TomDotTom 的原始答案):强>
如果您无法安装某些必需的开发包,还有一个选项可以禁用该警告:
In case you cannot install some of the required development packages, there's also an option to disable that warning:
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
如果您的 pip
本身受到 InsecurePlatformWarning
的影响并且无法从 PyPI 安装任何东西,则可以使用 此分步指南手动部署额外的 python 包.
If your pip
itself is affected by InsecurePlatformWarning
and cannot install anything from PyPI, it can be fixed with this step-by-step guide to deploy extra python packages manually.
这篇关于使用请求包时出现 SSL InsecurePlatform 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!