今天,要在新环境里运行一个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版本,但此时脚本不涉及安全的情况下,能够正常往下执行。

运行python脚本时,报错InsecurePlatformWarning: A true SSLContext object is not available,解决方法的更多相关文章

  1. 启动tomcat时,报错:IOException while loading persisted sessions: java.io.EOFException解决方法

    报错原因:加载持久化session错误,tomcat加载时读取的文件是是*.ser,session序列化文件,文件的位置是tomcat\work\Catalina\localhost,找到sessio ...

  2. 命令行运行Python脚本时传入参数的三种方式

    原文链接:命令行运行Python脚本时传入参数的三种方式(原文的几处错误在此已纠正) 如果在运行python脚本时需要传入一些参数,例如gpus与batch_size,可以使用如下三种方式. pyth ...

  3. 使用IDEA操作Hbase API 报错:org.apache.hadoop.hbase.client.RetriesExhaustedException的解决方法:

     使用IDEA操作Hbase API 报错:org.apache.hadoop.hbase.client.RetriesExhaustedException的解决方法: 1.错误详情: Excepti ...

  4. flask+sqlite3+echarts2+ajax数据可视化报错:UnicodeDecodeError: 'utf8' codec can't decode byte解决方法

    flask+sqlite3+echarts2+ajax数据可视化报错: UnicodeDecodeError: 'utf8' codec can't decode byte 解决方法: 将 py文件和 ...

  5. 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法

    pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...

  6. pip安装模块警告InsecurePlatformWarning: A true SSLContext object is not available.

    在用pip7.1.2版本安装第三方模块时出现了如下警告: /usr/lib/python2.7/site-packages/pip-7.1.2-py2.7.egg/pip/_vendor/reques ...

  7. 禁止requests请求https的提示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

     提示这个 InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from ...

  8. [经验总结] 在 windows 命令窗口中运行 python 脚本时提示 ModuleNotFoundError: No module named 'xxx'

    先给出的代码和目录结构 获取CPU代码如下: # -*- coding:utf-8 -*- ''' Created on Sep 10, 2018 @author: ''' import sys im ...

  9. 命令行运行python项目文件,报错:ModuleNotFoundError: No module named 'xxxx' 解决办法

    在pycharm中写好了自动化测试脚本,并能在pycharm中正常运行,由于要考虑到无人值守时能自动执行,执行时就需要脱离pycharm,直接能用命令执行.但是直接用命令执行用例文件:python3 ...

随机推荐

  1. SAP FI中配置“特别总帐标志” SGL

    SAP FI中配置“特别总帐标志” SGL   创建时间:2018年10月6日(星期六) 下午3:42 | 分类:未分类 | 字数:396 |  SAP FI中配置“特别总帐标志” SGL 2013年 ...

  2. [English] Time complexity wise this solution is the best among all

    Time complexity wise this solution is the best among all, we can do all operations in O(1) time. 时间复 ...

  3. linux debug tools

    linux modules: IO schedule.VFS.OOM.memory.net.process schedule kernel debug: perf(IO bound\CPU bound ...

  4. python使用adb获取Android Phone截图(解决Windows传输编码导致png文件损坏的问题)

    使用adb命令 ./adb shell screencap -p 可以截取当前屏幕,并且作为stdout,传给外部.那么对于python,我们可以用如下代码获取数据流. 使用Popen创建子进程用于读 ...

  5. CentOS7部署Flask+Gunicorn+Nginx+Supervisor

    1. Git客户端 Win10安装git for windows 1.1 设置Git全局参数 打开Git Bash $ git config --global user.name "Alic ...

  6. 多重if-else语句

    C语言自学之多重if-else语句 Dome : 某游戏对不同等级的积分的玩家赋予不同的荣誉称号,其对应关系如下: 积分>=10000分为钻石玩家 积分>=5000并且<10000为 ...

  7. Git常用命令及使用,GitLab/GitHub初探,Git/Svn区别

    Git安装配置及常用命令 0 Git本地分支管理 1 Git远程分支管理 2 Git Tag标签管理 3 Git Log日志 4 其它高级命令 5 常规使用及介绍 6 角色权限 7 分支定义 8 一般 ...

  8. markdown首行缩进

    首行缩进两个字符:(每个表示一个空格,连续使用两个即可)   半角的空格  全角的空格

  9. Element.scrollIntoView()

    Element.scrollIntoView() 方法让当前的元素滚动到浏览器窗口的可视区域内 语法 element.scrollIntoView(); element.scrollIntoView( ...

  10. Kubernetes 入门之Kubernetes 的基本概念和术语

    Kubernetes是什么?    他是一个全新的基于容器技术分布式架构领先方案:    他也是一个开放的开发平台:    他也是一个完备的分布式系统支撑平台:   Kubernetes的基本慨念和术 ...