我正在尝试将此 API 用于美联储经济数据 (FRED): https ://github.com/zachwill/fred
我安装了文档说需要的三个模块。我收到此错误:
import fred
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import fred
File "build\bdist.win32\egg\fred\__init__.py", line 1, in <module>
# Dummy file to make this a package.
File "build\bdist.win32\egg\fred\fred.py", line 21, in <module>
ImportError: cannot import name xml2dict
然后我安装了 xml2dict 并再次安装了 fred。当我现在先导入 xml2dict 然后导入 fred 时,我得到了完全相同的错误。
我很难学会在 Python 中安装模块,但我想我终于弄明白了。我似乎无法在这里找到我做错了什么,并且可以使用一些帮助。谢谢!
对于 Zach:这是我目前遇到的问题:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
fred.series('GNPCA')
File "build\bdist.win32\egg\fred\api.py", line 90, in series
return Fred().series(path, **kwargs)
File "build\bdist.win32\egg\fred\core.py", line 100, in series
return self.get('series', path, **kwargs)
File "build\bdist.win32\egg\fred\core.py", line 36, in get
request = requests.get(url, params=params)
File "C:\Python26\lib\site-packages\requests-0.13.2-py2.6.egg\requests\api.py", line 54, in get
return request('get', url, **kwargs)
File "C:\Python26\lib\site-packages\requests-0.13.2-py2.6.egg\requests\safe_mode.py", line 37, in wrapped
return function(method, url, **kwargs)
File "C:\Python26\lib\site-packages\requests-0.13.2-py2.6.egg\requests\api.py", line 42, in request
return s.request(method=method, url=url, **kwargs)
File "C:\Python26\lib\site-packages\requests-0.13.2-py2.6.egg\requests\sessions.py", line 230, in request
r.send(prefetch=prefetch)
File "C:\Python26\lib\site-packages\requests-0.13.2-py2.6.egg\requests\models.py", line 601, in send
raise ConnectionError(e)
ConnectionError: HTTPConnectionPool(host='api.stlouisfed.org', port=80): Max retries exceeded with url: /fred/series?series_id=GNPCA&api_key=