最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

解决Pythonrequests报错方法总结

来源:动视网 责编:小采 时间:2020-11-27 14:25:18
文档

解决Pythonrequests报错方法总结

解决Pythonrequests报错方法总结:这篇文章主要介绍了解决Python requests 报错方法集锦的相关资料,需要的朋友可以参考下python版本和ssl版本都会导致 requests在请求https网站时候会出一些错误,最好使用新版本。1 Python2.6x use requests一台老Centos机器上跑着古老的应用,
推荐度:
导读解决Pythonrequests报错方法总结:这篇文章主要介绍了解决Python requests 报错方法集锦的相关资料,需要的朋友可以参考下python版本和ssl版本都会导致 requests在请求https网站时候会出一些错误,最好使用新版本。1 Python2.6x use requests一台老Centos机器上跑着古老的应用,


这篇文章主要介绍了解决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_/egg/requests/api.py", line 52, in get
File "build/bdist.linux-x86_/egg/requests/api.py", line 40, in request
File "build/bdist.linux-x86_/egg/requests/sessions.py", line 209, in request
File "build/bdist.linux-x86_/egg/requests/models.py", line 624, in send
File "build/bdist.linux-x86_/egg/requests/models.py", line 300, in _build_response
File "build/bdist.linux-x86_/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

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

以上所述是小编给大家介绍的Python requests 报错方法集锦,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

文档

解决Pythonrequests报错方法总结

解决Pythonrequests报错方法总结:这篇文章主要介绍了解决Python requests 报错方法集锦的相关资料,需要的朋友可以参考下python版本和ssl版本都会导致 requests在请求https网站时候会出一些错误,最好使用新版本。1 Python2.6x use requests一台老Centos机器上跑着古老的应用,
推荐度:
标签: 方法 错误 python
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top