Error running provided example (gaap.py)
Eddolan opened this issue · comments
When I run gaap.py I am met with the following error:
File "/Users/xx/Coding/financial_fundamentals/venv/lib/python2.7/site-packages/xbrl/xbrl.py", line 144, in parseGAAP
context_tags = xbrl.find_all(name=re.compile(doc_root + "context",
AttributeError: 'file' object has no attribute 'find_all'
I can circumvent this error by simply deleting that line in the code, but I am still met with another error (shown below):
File "/Users/xx/Coding/python-xbrl/examples/xbrl.py", line 147, in parseGAAP
context_tags = xbrl.find_all(name=re.compile(doc_root + "context",
AttributeError: 'file' object has no attribute 'find_all'
Any idea what is going on here or how to resolve? I have attempted reinstall and manual instillation, but no solution yet.
Mostly likely you do not have beautifulsoup4
and/orlxml
installed correctly.
Try installing lxml
and beatuifulsoup4
and then running an interactive shell
me@tester:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> import bs4
>>> import xbrl
This will check if beautifulsoup4
, lxml
and xbrl
are installed and in your sys.path
You can check the sys.path by running the following from the interactive shell
me@tester:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
If these are not in your sys.path you can add them with
>>> sys.path.append('./my-python-xbrl-dir')
All was installed correctly. I got it to work by changing line 9 in gaap.py from:
xbrl = xbrl_parser.parseGAAP(file("../tests/sam-20130629.xml"))
to:
xbrl = xbrl_parser.parse(file("../tests/sam-20130629.xml"))
I'm not sure if you intended this to be .parseGAAP, and this attribute is only defined after calling XBRLParser.parse, which in this case I don't believe this is called before the attempted call to XBRLParser.parseGAAP. It could also be that something was configured incorrectly on my end.