我尝试在Quickstart for requests中执行第一个命令:
>>> import requests
>>> r = requests.get('https://github.com/timeline.json')
但是我收到以下错误消息:
Traceback (most recent call last):
File "./main.py", line 16, in <module>
requests.get('https://github.com/timeline.json')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/adapters.py", line 385, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:499: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
我对SSL证书完全不熟悉,但我怀疑它与Python在错误的地方有关。我下载了Python 2.7并使用它作为我的默认Python(我正在运行Mac OSX 10.6(Snow Leopard),它随Python 2.6一起提供)。我遇到了很多问题,我的Mac在错误的地方寻找Python的东西,直到我修复了路径并创建了符号链接,但我想知道是否还有其他与导致此SSL错误的升级有关的东西?或者它可能与某些东西没有任何关系。
我尝试搜索类似的questions并阅读了一些人的建议只是为了在verify=False
添加参数requests.get()
,但我不想做因为我认为这只是避免了真正的问题。感谢您帮助一个完整的新手。