8

I am trying to run the investopedia api located here: https://github.com/kirkthaker/investopedia-trading-api

I wrote the following script:

from investopedia import *
client = Account("emailaddress","password")

status = client.get_portfolio_status()
print status.account_val
print status.buying_power
print status.cash
print status.annual_return

I was able to install all the modules by running py -2.7 setup.py install for each dependency.

I am receiving the following error:

Traceback (most recent call last):
File "C:/Users/Z/PycharmProjects/investopedia/test.py", line 1, in <module>
    from investopedia import *
  File "C:\Users\Z\PycharmProjects\investopedia\investopedia.py", line 4, in <module>
    from bs4 import BeautifulSoup
  File "C:\Users\Z\AppData\Local\Enthought\Canopy\User\lib\site-packages\bs4\__init__.py", line 29, in <module>
    from .builder import builder_registry
  File "C:\Users\Z\AppData\Local\Enthought\Canopy\User\lib\site-packages\bs4\builder\__init__.py", line 297, in <module>
    from . import _html5lib
  File "C:\Users\Z\AppData\Local\Enthought\Canopy\User\lib\site-packages\bs4\builder\_html5lib.py", line 57, in <module>
    class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
AttributeError: 'module' object has no attribute '_base'

Do you know how to resolve this?

martineau
  • 119,623
  • 25
  • 170
  • 301
hasanzuav
  • 554
  • 5
  • 15

2 Answers2

23

Solved this by using

pip2.7 install --upgrade beautifulsoup4
pip2.7 install --upgrade html5lib

Works beautifully now.

hasanzuav
  • 554
  • 5
  • 15
  • I suggest that, to better help others with a similar problem, that you [edit] your answer and say why doing these operations was necessary. – martineau Mar 26 '17 at 00:52
  • I will be honest, I am not sure why this was necessary. I just was trying things from this post: http://stackoverflow.com/questions/38447738/beautifulsoup-html5lib-module-object-has-no-attribute-base – hasanzuav Mar 26 '17 at 00:53
  • 1
    `pip install -help` -> `--upgrade` option: "Upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used." So it sounds like the problem was you didn't have the latest version of the two packages even those an older version was installed. – martineau Mar 26 '17 at 01:07
0

Solved this by using conda

conda install beautifulsoup4
conda install html5lib
Shiva Manhar
  • 673
  • 8
  • 19