python问题之requests\packages\urllib3\util\ssl_.py:100: InsecurePlatformWarning

requests\packages\urllib3\util\ssl_.py:100: 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.

最近在写一下爬虫,前面用flask和jinja2还有python的mysql连接做了下简单的数据交互的登录验证,比起java的struts这样的控制,确实python来的更加简单。

为什么要用python,一次我用java解密一个东西的时候,半天解不出来,base64写起来也是乱七八糟,到java8自带了。后面用了python尝试了下,两行代码。

使用requests时,访问的是https类型的网址,因为https用了ss加密,会报这种insecureplatformwarning,平台非安全警告,大概与https有关,然后查了下解决办法。

直接警告信息的网址 Advanced Usage - urllib3 2.0.0.dev0 documentation

InsecurePlatformWarning
New in version 1.11.


Certain Python platforms (specifically, versions of Python earlier than 2.7.9) have restrictions in their ssl module that limit the configuration that urllib3 can apply. In particular, this can cause HTTPS requests that would succeed on more featureful platforms to fail, and can cause certain security features to be unavailable.


If you encounter this warning, it is strongly recommended you upgrade to a newer Python version, or that you use pyOpenSSL as described in the OpenSSL / PyOpenSSL section.


在限制urllib3所应用的配置的ssl模块,在某些Python版本(特别是2.7.9之前的)有限制,特别的是,这导致HTTPS请求在本来更多的功能平台成功的变成失败,还有导致某些安全功能模块失效。
如果你遇到这个警告,强烈建议升级到高版本的python版本,或者在OpenSSL/PyOpenSSL部分描述的,你要使用pyOpenSSL。

继续查找了一下解决办法:

InsecurePlatformWarning - Insecure Platform Warning - A true SSLContext object is not available. · Issue #339 · plotly/plotly.py · GitHub

按照文章的解决办法,使用$ pip install requests[security] 即可,安装完之后不再有警告。
这个将会安装pyOpenSSL,ndg-httpsclient,pyasn1。


用此命令之前,python环境先要安装pip。pip是安装管理python包的工具。
 

如何解决:/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.15) or chardet (3.0.4) doesn't match a supported version! warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported " Traceback (most recent call last): File "/home/data/minjie.yu/.local/bin/streamlit", line 5, in <module> from streamlit.web.cli import main File "/home/data/minjie.yu/.local/lib/python3.8/site-packages/streamlit/__init__.py", line 55, in <module> from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator File "/home/data/minjie.yu/.local/lib/python3.8/site-packages/streamlit/delta_generator.py", line 36, in <module> from streamlit import config, cursor, env_util, logger, runtime, type_util, util File "/home/data/minjie.yu/.local/lib/python3.8/site-packages/streamlit/cursor.py", line 18, in <module> from streamlit.runtime.scriptrunner import get_script_run_ctx File "/home/data/minjie.yu/.local/lib/python3.8/site-packages/streamlit/runtime/__init__.py", line 16, in <module> from streamlit.runtime.runtime import Runtime as Runtime File "/home/data/minjie.yu/.local/lib/python3.8/site-packages/streamlit/runtime/runtime.py", line 29, in <module> from streamlit.proto.BackMsg_pb2 import BackMsg File "/home/data/minjie.yu/.local/lib/python3.8/site-packages/streamlit/proto/BackMsg_pb2.py", line 5, in <module> from google.protobuf.internal import builder as _builder ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/home/data/minjie.yu/.local/lib/python3.8/site-packages/google/protobuf/internal/__init__.py)
07-16
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

iaiti

赏顿早餐钱~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值