module 'pandas_datareader' has no attribute 'get_data_yahoo'

孤街浪徒 提交于 2019-12-10 18:13:18

问题


I'm trying to get stock market history using pandas-datareader as specified in this SO question.

I've installed pandas-datareader with:
conda install -c https://conda.anaconda.org/anaconda pandas-datareader I'm running on windows 10, with pycharm, and anaconda3 interpreter

I'm trying to run the very basic:

import pandas_datareader as pdr
pdr.get_data_yahoo('AAPL')

But I get an error: File "D:/Dropbox/Duo/documents docs/Projects/F500AquisitionQuality/m_and_a_quality/stock_utils.py", line 2, in <module> pdr.get_data_yahoo('AAPL') AttributeError: module 'pandas_datareader' has no attribute 'get_data_yahoo'

Please note that the filename has nothing to do with pandas as in this reddit comment (the only related thing i could find online)


回答1:


There is a problem with get_data_yahoo in version 0.4.0 (because Yahoo changed API).

To fix it you can install version 0.4.1 (it's not merged yet https://github.com/pydata/pandas-datareader/pull/331 as for May 20 2017)

Following code helped me. I cloned pandas-datareader source code, changed branch, installed package from source code using pip3

git clone https://github.com/pydata/pandas-datareader cd pandas-datareader/ git remote add rgkimball http://github.com/rgkimball/pandas-datareader git fetch rgkimball fix-yahoo git checkout fix-yahoo pip3 uninstall pandas_datareader python3 setup.py install




回答2:


Couldn't figure out the problem, but I did solve it by running

pip uninstall pandas-datareader

and then pip install pandas-datareader




回答3:


Well, you just need 2 things First uninstall the lib -

pip uninstall pandas-datareader

And then need to install it using pip3 (Please notice it is pip3)

pip3 install pandas-datareader


来源:https://stackoverflow.com/questions/44025037/module-pandas-datareader-has-no-attribute-get-data-yahoo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!