fredapi icon indicating copy to clipboard operation
fredapi copied to clipboard

Receiving an AttributeError indicating that the API is returning XML data

Open kburchfiel opened this issue 4 years ago • 2 comments

After installing the latest version of fredapi and running the following code (from the library homepage):

from fredapi import Fred
fred = Fred(api_key=fred_key)
data = fred.get_series('SP500')

I received the following error message:

[AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren']()

It seems as though the API is retrieving XML data. How can I resolve this?

kburchfiel avatar Apr 15 '22 00:04 kburchfiel

Update: I installed the latest version available on conda-forge (0.42), but this is less recent than the version available through pip (0.50). After using pip to install the latest version, the code worked. So the error is probably related to conda-forge's outdated fredapi version.

kburchfiel avatar Apr 15 '22 00:04 kburchfiel

yes this issue should have been solved since version 0.4.3, similar discussion here: https://github.com/mortada/fredapi/issues/41

mortada avatar Apr 15 '22 00:04 mortada