EodHistoricalData / python-eodhistoricaldata

Download data from EOD historical data https://eodhd.com/ using Python, Requests and Pandas.
MIT License
94 stars 40 forks source link

stringIO broken causing library to break. #1

Closed elocke-abroaden closed 5 years ago

elocke-abroaden commented 5 years ago

I installed the libary but when trying to run it, I receive an import error staying that it cannont import name "StringIO":

ImportError                               Traceback (most recent call last)
<ipython-input-18-8a03ebd3fd3d> in <module>
      2 import requests
      3 import pandas as pd
----> 4 from eod_historical_data import get_eod_data

~/.local/lib/python3.6/site-packages/eod_historical_data/__init__.py in <module>
----> 1 from .data import (get_api_key, get_eod_data, get_dividends,  # noqa
      2                    get_exchange_symbols, get_exchanges,  # noqa
      3                    get_currencies, get_indexes)  # noqa

~/.local/lib/python3.6/site-packages/eod_historical_data/data.py in <module>
      2 import requests
      3 import pandas as pd
----> 4 from pandas.compat import StringIO
      5 from ._utils import (_init_session, _format_date,
      6                      _sanitize_dates, _url, RemoteDataError)

ImportError: cannot import name 'StringIO'

I'm running Python 3.6.8.

I checked around and it seems that StringIO is either no longer supported or is not installed in the latest version of Pandas.

Any idea on a workaround?

deios0 commented 5 years ago

Looks like it's a pandas bug: "Work around is to roll back to prior version of Pandas 0.24.2 pip3 install --upgrade pandas==0.24.2"

https://github.com/pydata/pandas-datareader/issues/655

femtotrader commented 5 years ago

If you can live without Python 2.x and are now using Python 3.x you can simply change

from pandas.compat import StringIO

to

from io import StringIO

Anyway I will remove Python 2.7 compat in 2020

See https://www.python.org/dev/peps/pep-0373/

elocke-abroaden commented 5 years ago

Excellent, thanks for the update. I'll amend the line in the code. Thanks again.