我正在尝试将此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=
最佳答案
我是fred
包的开发人员。这完全是我的错—我错误地配置了setup.py
文件,并且我刚刚推送了一个应解决此问题的更新。对困惑感到抱歉!
关于python - 在Python中使用FRED API遇到问题-无法加载模块,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11440263/