我有一个非常基本的脚本,可以从服务器上获取JSON响应,在一台Mac上可以运行,而在另一台上则出现以下错误。
File "script.py", line 10, in <module>
r = requests.get(url = URL)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 56, 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 488, 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 609, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:661)
这是代码。
start = "2020-01-01"
end = "2020-03-01"
URL = "https://www.url.app/api/v1/item.php?start=%s&end=%s" % (start, end)
r = requests.get(url = URL)
print(r.tojson())
谁能告诉我哪里出了问题?两台计算机都有Python 2.7
答案 0 :(得分:0)
对我来说,这有效
pip install requests[security]
我在这里找到了这个答案: https://github.com/psf/requests/issues/3605#issuecomment-256425497