Error importing pandas_datareader, "ImportError: can not import name 'is_list_like'"

0

After installing with pip pandas_datareader , at the moment of importing it, it generates the following error:

>>> import pandas_datareader as web
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pandas_datareader as web
  File "C:\Python\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
    from .data import (DataReader, Options, get_components_yahoo,
  File "C:\Python\lib\site-packages\pandas_datareader\data.py", line 14, in <module>
    from pandas_datareader.fred import FredReader
  File "C:\Python\lib\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'

What is owed and how can I solve it?

    
asked by ge2209 12.08.2018 в 01:45
source

2 answers

0

There is a name of a core package that you have to redefine, it seems to be an error of the module, try to do the imports in the following way:

import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader as web 
    
answered by 12.08.2018 в 02:22
0

The exception is because is_list_like has moved from pandas.core.common to pandas.api.types in version 0.23 of Pandas. The error is reported in the pandas_datareader repository and corrected in the current dev version.

At the moment that the new stable version of the library is generated and it is uploaded to PyPi, the error will be corrected. Meanwhile, you can do the following:

  • Install the dev version from GitHub:

    $ python -m pip install git+https://github.com/pydata/pandas-datareader.git
    
  • Create an alias before the import in your main script:

    >>> import pandas as pd
    >>> pd.core.common.is_list_like = pd.api.types.is_list_like 
    >>> import pandas_datareader
    
  • Modify the source code of the package in the directory where you have it installed indicating the correct import , in a similar way as in the commit linked above.

  • Install a version earlier than 0.23 of Pandas:

    $ python -m pip install pandas==0.22 --force-reinstall
    
answered by 12.08.2018 в 02:41