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

首頁 > 編程 > Python > 正文

解決Python requests 報錯方法集錦

2019-11-25 16:18:44
字體:
來源:轉載
供稿:網友

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 岑溪市| 怀集县| 开阳县| 凌云县| 巴东县| 乌拉特后旗| 龙陵县| 尚义县| 建宁县| 上饶市| 会同县| 郓城县| 凌海市| 铁岭县| 岗巴县| 乌鲁木齐市| 永顺县| 平南县| 喀喇沁旗| 平舆县| 宁明县| 周至县| 澳门| 行唐县| 荣昌县| 白银市| 南投县| 清水县| 崇信县| 博乐市| 淄博市| 西林县| 定陶县| 吕梁市| 黑龙江省| 玉门市| 黎平县| 开江县| 茌平县| 疏勒县| 弋阳县|