python版本号和ssl版本号都会导致 requests在请求https站点时候会出一些错误,最好使用新版本号。

1 Python2.6x use requests

一台老Centos机器上跑着古老的应用,加了一个新模块之后报错 报错 InsecurePlatformWarning: A true SSLContext object is not available.

/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:132: 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 newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning

解决的方法

使用老版本号的 requests

$pip install requests==2.5.3

或者这样安装

$ pip install requests[security]

2 SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

错误例如以下 版本号 python2.7.5

Traceback (most recent call last):
File "./test.py", line 24, in <module>
response = requests.get(url1, headers=headers)
File "build/bdist.linux-x86_64/egg/requests/api.py", line 52, in get
File "build/bdist.linux-x86_64/egg/requests/api.py", line 40, in request
File "build/bdist.linux-x86_64/egg/requests/sessions.py", line 209, in request
File "build/bdist.linux-x86_64/egg/requests/models.py", line 624, in send
File "build/bdist.linux-x86_64/egg/requests/models.py", line 300, in _build_response
File "build/bdist.linux-x86_64/egg/requests/models.py", line 611, in send
requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

解决方法

能够禁用 verify

>>> requests.get('https://google.com', verify=False)

问题地址 python-requests-throwing-up-sslerror

3 SSLError: bad handshake

SSLError: bad handshake: Error([(‘SSL routines’, ‘SSL3_GET_SERVER_CERTIFICATE’, ‘certificate verify failed’)],) python2.7.5

pip uninstall -y certifi && pip install certifi==2015.04.28

讨论參见: https://github.com/rackspace/pyrax/issues/601

Python requests 报错解决集锦的更多相关文章

  1. python+eclipse 引用 import requests报错解决。

    用pip install requests命令执行安装下 再重启eclipse就好了. 用pip install requests命令执行安装下 再重启eclipse就好了. 用pip install ...

  2. 第一次打开pycharm运行python文件报错”No Python interpreter selected“问题的解决办法

    前面没有细讲,这里细述一下安装pycharm后,第一次打开pycharm运行python文件报错"No Python interpreter selected"问题的解决办法. 出 ...

  3. pycharm 中 import requests 报错

    一 , 使用Pycharm来抓取网页的时候,要导入requests模块,但是在pycharm中 import requests 报错. 原因: python中还没有安装requests库 解决办法: ...

  4. Aasible中cryptography兼容性报错解决办法

    Aasible中cryptography兼容性报错解决办法 1 Ansible中使用ansible --version查看版本,报错信息如下: ERROR! Unexpected Exception, ...

  5. vue 项目 npm install 报错解决

    node-sass 安装报错解决办法 2017年04月15日 14:34:25 阅读数:20189 E:\kibana>npm install node-sass > node-sass@ ...

  6. 调用python脚本报错/usr/bin/env: python : No such file or directory

    一.调用python脚本报错 /usr/bin/env: python: No such file or directory 二.解决方法 原因是在windows上编写的脚本,使用dos2unix对脚 ...

  7. selenium + PhantomJS使用时 PhantomJS报错解决

    selenium + PhantomJS使用时 PhantomJS报错解决 在做动态网页爬虫时用到了selenium + PhantomJS,安装好之后运行时报错: UserWarning: Sele ...

  8. sphinx :undefined reference to `libiconv' 报错解决办法

    sphinx :undefined reference to `libiconv' 报错解决办法   2013-11-30 21:45:39 安装sphinx时不停报错...郁闷在make时报错,错误 ...

  9. redis运用连接池报错解决

    redis使用连接池报错解决redis使用十几小时就一直报异常 redis.clients.jedis.exceptions.JedisConnectionException: Could not g ...

随机推荐

  1. 【JAVAWEB学习笔记】11_XML

    今日内容介绍 编写服务器软件,访问指定配置内容 访问tomcat下已经发布的web项目 今日内容学习目标 可以编写xml存放任意内容 通过DTD约束编写指定格式的XML 通过Schema约束编写指定格 ...

  2. bWAPP练习--injection篇SQL Injection (GET/Search)

    SQL注入: SQL注入,就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令.具体来说,它是利用现有应用程序,将(恶意)的SQL命令注入到 ...

  3. JAVA基础关键字小结一

    基础部分总是看起来简单,若要明白原理和使用场景,需要慢慢的体会. 本文对常用的关键字如final,transient,volatile,static以及foreach循环的原理重新梳理了一遍. 一.f ...

  4. SpringBoot学习(五)

    package org.springboot.sample.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; impor ...

  5. Tsinsen 拉拉队排练

    建回文树,然后判断长度奇偶性,统计下来排序即可. 题目链接:http://www.tsinsen.com/ViewGProblem.page?gpid=A1255 By:大奕哥 #include< ...

  6. 1.7(SQL学习笔记)游标

    一.游标简介 SELECT语句得到的是一个结果集,有时我们需要对结果集中的单条数据进行处理. 这时就需要使用游标,游标定义时和一个SELECT语句的结果集关联在一起. 游标执行这个结果集,可以在结果集 ...

  7. [转]Eclipse 项目转移到Android Studio遇到的问题

    1.Android Studio直接导入项目是copy原项目的,无法纳入代码管控 解决方案: 英文地址:http://developer.android.com/sdk/installing/migr ...

  8. mybatis源码分析(3)-----SqlSessionHolder作用

    1. sqlSessionHolder 是位于mybatis-spring 包下面,他的作用是对于sqlSession和事务的控制 sqlSessionHolder 继承了spring的Resourc ...

  9. 微信小程序导航栏,下面内容滑动,上册导航栏跟着滑动,内容随着导航栏滑动

    16.类似微信导航栏滑动.png 今日头条导航栏,下面滑动上面跟着滑动 index.wxml <swiper class="content" style="heig ...

  10. CentOS下的RPM包制作教程收集(rpmbuild)

    http://www.jinbuguo.com/redhat/rpmbuild.html(中文手册) https://www.linuxidc.com/Linux/2016-09/134955.htm ...