模块'pandas_datareader'没有属性'get_data_yahoo'

问题描述 投票:2回答:3

我正在尝试使用this SO question中指定的pandas-datareader获取股市历史。

我已经安装了pandas-datareader: conda install -c https://conda.anaconda.org/anaconda pandas-datareader我在Windows 10上运行,有pycharm和anaconda3解释器

我正在尝试运行最基本的:

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

但我收到一个错误: 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'

请注意,文件名与pazas无关,如this reddit comment(我在网上找到的唯一相关内容)

python-3.x anaconda yahoo-finance pandas-datareader
3个回答
2
投票

版本0.4.0中的get_data_yahoo存在问题(因为Yahoo更改了API)。

要解决此问题,您可以安装0.4.1版本(2017年5月20日尚未合并https://github.com/pydata/pandas-datareader/pull/331

以下代码帮助了我。我克隆了pandas-datareader源代码,更改了分支,使用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


1
投票

无法弄清楚问题,但我确实通过运行来解决它

pip uninstall pandas-datareader

然后pip install pandas-datareader


1
投票

好吧,你只需要2件事首先卸载lib -

pip uninstall pandas-datareader

然后需要使用pip3安装它(请注意它是pip3)

pip3 install pandas-datareader
© www.soinside.com 2019 - 2024. All rights reserved.