ImportError: cannot import name 'PandasError'
Asked Answered
B

3

10

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

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

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)

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

Thanks very much for any help!

Bobby answered 5/5, 2017 at 16:21 Comment(0)
V
18

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:

pip install -U pandas==0.19.2
Varick answered 6/5, 2017 at 8:44 Comment(1)
Great !! This version works. Thanks very much for your swift answer!Bobby
U
5

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

sudo pip install -U pandas_datareader
Uredium answered 9/8, 2017 at 20:40 Comment(0)
C
0

I may already be too late to the discussion but I encountered this earlier today using a brand new Azure Compute that I spun up, I did all the steps above and was always encountering the error.

It may not be explicitly stated above but restarting the kernel AFTER the steps above fixed the issue.

Citadel answered 8/11, 2021 at 9:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.