国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

解決Python requests 報錯方法集錦

2020-02-23 04:26:28
字體:
來源:轉載
供稿:網友

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 報錯方法集錦,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵川县| 容城县| 温泉县| 海阳市| 仙游县| 襄垣县| 泸水县| 沈阳市| 柯坪县| 芦溪县| 柘城县| 忻城县| 新营市| 客服| 乐亭县| 辽中县| 亚东县| 大港区| 清远市| 法库县| 临江市| 罗江县| 政和县| 梅州市| 和田市| 榆树市| 桐庐县| 旺苍县| 乐山市| 固镇县| 盘山县| 霸州市| 凤冈县| 玉山县| 五台县| 南澳县| 汝南县| 五指山市| 肥乡县| 中宁县| 莫力|