Golightly
Golightly

Reputation: 3

Python3: import pandas_datareader ImportError

I'm pretty new to Python, but have Python 3.6 installed, and running a few other programs perfectly. I'm trying to pull data using the pandas_datareader module but keep running into this issue. Operating system: OSX.I've visited the other threads on similar errors and tried their methods to no avail.

Additional concern: When using Sublime Text, if I run it as a Python (instead of Python3) build, it funcitons fine, but all my other accompanying programs are written on Python3. Is there a way of making this work on 3.6 that I'm missing?

I have already visited the 'is_list_like' error question, and have changed the fred.py file to pandas.api.types in the import line.

Traceback (most recent call last):
  File 
"/Users/scottgolightly/Desktop/python_work/data_read_practice.py", line 
3, in <module>
    import pandas_datareader.data as web
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- 
packages/pandas_datareader/__init__.py", line 2, in <module>
    from .data import (DataReader, Options, get_components_yahoo,
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- 
packages/pandas_datareader/data.py", line 14, in <module>
    from pandas_datareader.fred import FredReader
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- 
packages/pandas_datareader/fred.py", line 1, in <module>
    from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'

Upvotes: 0

Views: 1500

Answers (2)

Nils
Nils

Reputation: 2695

Small workaround is to define it like this:

import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader

Upvotes: 0

Daniel R. Livingston
Daniel R. Livingston

Reputation: 1229

As has been noted, is_list_like has been moved from pandas.core.common to pandas.api.types.

There are several paths forward for you.

  1. My (highly) recommended solution: download Conda and set up an environment with a version of Pandas prior to v0.23.0.

  2. You can install the development version of Pandas, with a patch in place:

    pip install git+https://github.com/pydata/pandas-datareader.git

  3. Since you say that you have a version of Pandas in a different environment that works, I suspect the Python calling it is version 2.X. If so, try using past.autotranslate to import the older version of Pandas.

  4. If this working version of Pandas actually belongs to a Python 3.X site-packages, then you can manually import it using:

    sys.path.insert(0, '/path/to/other/pandas')

Upvotes: 1

Related Questions