Search code examples
pythonimportmoduleinstallationeconomics

Trouble using FRED API in Python -- cannot load module


I am trying to use this API for the Federal Reserve Economic Data (FRED): https://github.com/zachwill/fred

I installed the three modules that the documentation said are required. I get this error:

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

I then installed xml2dict and installed fred again. When I now do import xml2dict first and then import fred, I get the exact same error.

I had a hard time learning to install modules in Python but thought I finally had it figured out. I can't seem to find what I am doing wrong here though and could use some help. Thanks!

For Zach: This is the problem I'm currently having:

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=

Solution

  • 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!