gpt4 book ai didi

python - pandas-datareader 世界银行 API 损坏

转载 作者:行者123 更新时间:2023-12-04 15:24:45 26 4
gpt4 key购买 nike

为什么世界银行 API 的最新示例不适用于 pandas-datareader

https://pandas-datareader.readthedocs.io/en/latest/remote_data.html#remote-data-wb

from pandas_datareader import wb

matches = wb.search('gdp.*capita.*const')
dat = wb.download(indicator='NY.GDP.PCAP.KD', country=['US', 'CA', 'MX'], start=2005, end=2008)
print(dat)

给我这个:

Traceback (most recent call last):
File "C:\Python36\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Python36\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Python36\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Python36\lib\site-packages\urllib3\connection.py", line 326, in connect
ssl_context=context)
File "C:\Python36\lib\site-packages\urllib3\util\ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Python36\lib\ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "C:\Python36\lib\ssl.py", line 814, in __init__
self.do_handshake()
File "C:\Python36\lib\ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "C:\Python36\lib\ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python36\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Python36\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Python36\lib\site-packages\urllib3\util\retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.worldbank.org', port=443): Max retries exceeded with url: /v2/indicators?per_page=50000&format=json (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Jason/Google Drive/pycharm/test.py", line 3, in <module>
matches = wb.search('gdp.*capita.*const')
File "C:\Python36\lib\site-packages\pandas_datareader\wb.py", line 938, in search
return WorldBankReader(**kwargs).search(string=string, field=field, case=case)
File "C:\Python36\lib\site-packages\pandas_datareader\wb.py", line 809, in search
indicators = self.get_indicators()
File "C:\Python36\lib\site-packages\pandas_datareader\wb.py", line 745, in get_indicators
resp = self._get_response(url)
File "C:\Python36\lib\site-packages\pandas_datareader\base.py", line 155, in _get_response
response = self.session.get(url, params=params, headers=headers)
File "C:\Python36\lib\site-packages\requests\sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "C:\Python36\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python36\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Python36\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.worldbank.org', port=443): Max retries exceeded with url: /v2/indicators?per_page=50000&format=json (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))

它曾经在 0.7 版本上工作。我已经有一年左右没有运行它了,今天运行它并给了我同样的错误,所以我升级到最新的 datareader 版本,但它仍然无法正常工作。

最佳答案

我没有解决方案。但它在星期五工作。世界银行最近更新了他们的证书,所以这可能就是原因。我在我的应用程序中使用世界银行数据,所以卡在这里。

我已经在 pandas_datareader github 页面中提出了一个请求:https://github.com/pydata/pandas-datareader/issues/791

关于python - pandas-datareader 世界银行 API 损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62504597/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com