Python requests 报错解决集锦
Posted orangleliu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python requests 报错解决集锦相关的知识,希望对你有一定的参考价值。
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=True)
问题地址 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
以上是关于Python requests 报错解决集锦的主要内容,如果未能解决你的问题,请参考以下文章
ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll(代码片
springboot报错说 Failed to parse multipart servlet request; nested exception is java.io.IOException(代码片
from torchtext.datasets import text_classification 报错解决:cannot import name ‘text_classification‘(代码片
报错:java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null“解决的方式(代码片
Docker 问题集锦(26) - 解决报错:unable to find user root: no matching entries in passwd file