• 运行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版本,但此时脚本不涉及安全的情况下,能够正常往下执行。

     

    努力奋斗,做更好的自己!
  • 相关阅读:
    031-进阶(日志)
    Django 路由系统
    C++ 面向对象(接口-抽象类)
    C++ 面向对象(多态)
    C++ 面向对象(数据抽象)
    三十、首页列表显示全部问答,完成问答详情页布局
    二十九、制作首页的显示列表
    二十八、发布功能完成
    二十七、登录之后更新导航
    二十六、完成登录功能,用session记住用户名
  • 原文地址:https://www.cnblogs.com/jjstrip/p/9494150.html
Copyright © 2020-2023  润新知