pandas 导入错误:无法导入名称“PandasError”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43809620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 03:32:42  来源:igfitidea点击:

ImportError: cannot import name 'PandasError'

pythonmacospython-3.xpandaspandas-datareader

提问by Tobias Nilsson

I am very new to Python 3x, running on a mac.

我对在 Mac 上运行的 Python 3x 非常陌生。

Currently using a sentdex tutorial for python with finance, tried running the following script:

目前正在使用财务 python 的senddex教程,尝试运行以下脚本:

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())

However this returns the following error message:

但是,这会返回以下错误消息:

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'

I think maybe there's something wrong with panda-datareader itself, which I've ensured has been upgraded to most recent version (pandas-datareader 0.3.0.post0)

我认为 panda-datareader 本身可能有问题,我确保已将其升级到最新版本(pandas-datareader 0.3.0.post0)

Is there an older version I can install instead? I've been using pip3 to install via mac terminal.

有没有我可以安装的旧版本?我一直在使用 pip3 通过 mac 终端安装。

Thanks very much for any help!

非常感谢您的帮助!

回答by Gabriele

I think you installed pandas v. 0.20.1 released yesterday. pandas-datareader is still not compatible with this version, for the moment you should stay on pandas 0.19.2:

我想你安装了昨天发布的 pandas v. 0.20.1。pandas-datareader 仍然不兼容这个版本,目前你应该继续使用 pandas 0.19.2:

pip install -U pandas==0.19.2

回答by Abdou

The latest version of pandas_datareader(0.5.0) takes care of this import error. You can install it with pip:

pandas_datareader( 0.5.0)的最新版本处理了这个导入错误。您可以使用以下命令安装它pip

sudo pip install -U pandas_datareader