运行python脚本时,报错InsecurePlatformWarning: A true SSLContext object is not available,解决方法...

今天,要在新环境里运行一个python脚本,遇到下面的报错:

/usr/lib/python2.7/site-packages/urllib3/util/ssl_.py:160: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a new......

报错跟安全策略相关,网上搜了下,是因为python版本的原因(用的是python2.7.5),解决办法要么升级python 版本,要么安装requests,

本着牵动最小的原则,决定采用后者,如下:

pip install requests[security]   

安装完成后,重新运行python脚本,还是一样的报错,又尝试了

pip install pyopenssl ndg-httpsclient pyasn1(等同于安装requests)

安装完成后,重新运行python脚本,还是一样的报错,想到一个惯用伎俩——upgrade

pip install --upgrade requests[security]

安装完成后,重新运行python脚本,果然,不再报InsecurePlatformWarning错了

 

题外话:InsecurePlatformWarning的错没有了,但又报了另一个错CryptographyDeprecationWarning,详细信息如下:

/usr/lib64/python2.7/site-packages/cryptography/hazmat/primitives/constant_time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.

  utils.DeprecatedIn23

 

提醒升级python版本,但此时脚本不涉及安全的情况下,能够正常往下执行。

 

 

转载于:https://www.cnblogs.com/jjstrip/p/9494150.html

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值