2017-05-05 168 views
10

我对Python 3x非常新,在Mac上运行。ImportError:无法导入名称'PandasError'

目前使用sentdex教程蟒蛇金融,试图运行下面的脚本:

import datetime as dt 
import matplotlib.pyplot as plt 
from matplotlib import style 
import pandas as pd 
import pandas_datareader.data as web 

style.use('ggplot') 

start = dt.datetime(2000,1,1) 
end = dt.datetime(2016,12,31) 

df = web.DataReader('TSLA', 'yahoo', start, end) 
print(df.head()) 

然而,这将返回以下错误信息:

Traceback (most recent call last): 
    File "F:\Downloads\Python Work\try figuring thigns out\finance\try.py", line 1, in <module> 
    import pandas_datareader.data as web 
    File "C:\Python36\lib\site-packages\pandas_datareader\__init__.py", line 3, in <module> 
    from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma, # noqa 
    File "C:\Python36\lib\site-packages\pandas_datareader\data.py", line 7, in <module> 
    from pandas_datareader.google.daily import GoogleDailyReader 
    File "C:\Python36\lib\site-packages\pandas_datareader\google\daily.py", line 1, in <module> 
    from pandas_datareader.base import _DailyBaseReader 
    File "C:\Python36\lib\site-packages\pandas_datareader\base.py", line 13, in <module> 
    from pandas_datareader._utils import (RemoteDataError, SymbolWarning, 
    File "C:\Python36\lib\site-packages\pandas_datareader\_utils.py", line 5, in <module> 
    from pandas.core.common import PandasError 
ImportError: cannot import name 'PandasError' 

我想也许有一些错误熊猫-datareader本身,我已确保已升级到最新版本(pandas-datareader 0.3.0.post0)

是否有更旧的版本我可以安装吗?我一直在使用pip3通过mac终端进行安装。

非常感谢您的帮助!

回答

18

我想你安装了昨天发布的熊猫v。0.20.1。 大熊猫,DataReader的仍是与此版本不兼容,对于时刻,你应该留在大熊猫0.19.2:

pip install -U pandas==0.19.2 
+0

太棒了!此版本的作品。非常感谢您的迅速回答! –

+0

谢谢。它解决了。 –

5

pandas_datareader0.5.0)的最新版本借此导入错误的照顾。您可以安装它pip

sudo pip install -U pandas_datareader 
+0

它适用于anaconda,谢谢! – addoil

相关问题