时间:2021-05-22
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
讨论参见: https://github.com/rackspace/pyrax/issues/601
以上所述是小编给大家介绍的Python requests 报错方法集锦,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
解决python-v报错问题的方法:在cmd命令行中输入“python-v”报错是因为没有将python的安装路径添加到系统环境变量path中,将python的
今天使用Pycharm来抓取网页图片时候,要导入requests模块,但是在pycharm中importrequests时候报错。原因:python中还没有安装
用python查看网页代码的方法:1、使用“import”导入requests包importrequests2、使用requests包的get()函数通过网页链
解决Python3控制台输出InsecureRequestWarning的问题问题:使用Python3requests发送HTTPS请求,已经关闭认证(veri
本文实例讲述了Python使用pickle模块报错EOFErrorRanoutofinput的解决方法。分享给大家供大家参考,具体如下:遇到了EOFError: