1

我正在尝试将此 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=
4

2 回答 2

4

I'm the developer of the fred package. This is completely my fault — I had the setup.py file incorrectly configured, and I just pushed an update that should take care of this issue. Sorry for the confusion!

于 2012-07-11T22:45:16.287 回答
3

一般安装模块的提示:

通常最简单的方法是使用pipor easy_install(或二进制安装程序,如果有的话) - 这样您所需要做的就是easy_install fred自动下载所需的所有内容(只要配置正确)。

查看http://pypi.python.org/pypi/setuptools上的 setuptools并为您的适当操作系统版本安装它。然后,您将获得一个名为的命令,该命令easy_install将根据您的操作系统/设置安装在某个位置(尽管文档确实提到了位置)。[你也可以easy_install pip作为pip有效easy_install的继任者]

Then hopefully, all you need to do is easy_install fred (which will automatically find at http://pypi.python.org/pypi/fred), and it will download the latest version and all dependencies for you. Fire up your interpreter and import fred should "just work".

于 2012-07-11T20:23:13.953 回答