Fixing pandas_datareader ImportError: cannot import name ‘is_list_like’

pandas_datareader ImportError: cannot import name ‘is_list_like’ is an error which occurs when there are compatibility issues between pandas_datareader and pandas.

This post is my attempt to explain to you why this error occurs and how you can solve it, I will also include multiple solutions that could be considered as alternative fixes to the error.

Exploring the Error : pandas_datareader ImportError: cannot import name ‘is_list_like’

pandas datareader ImportError cannot import name is_list_like is an error which occurs when there are compatibility issues between pandas_datareader and pandas.

Your error message should match the one bellow. We want to avoid confusion by not mixing between error messages.

                                                                       #
...
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'
                                                                       #

Bellow is a number of tested solutions that I have tried and worked for me.

Solution 1 : install the latest version of pandas_datareader , ( now : pip install pandas-datareader=0.1.0 )

First, we should understand the root of the issue, the problem here is that, is_list_like is moved to pandas.api.types in the version of pandas_datareader you have. That is why you are getting the import error.

The first solution is to upgrade to the latest version of pandas_datareader. We can do that in two steps.

First step is to uninstall pandas_datareader, you can do that by using the command bellow.

                                                                       #
pip uninstall pandas_datareader
                                                                       #

The second step is to install the latest version of pandas-datareader using the command bellow.

                                                                       #
pip install pandas-datareader=0.1.0
                                                                       #

As of now, pandas-datareader version 0.10.0 is the latest version. After running your code the error should be gone.

Solution 2 : Manually define is_list_like since it moved to pandas.api.types

This solution is for those who do not wish to change the version of pandas-datareader .

You can just define is_list_like using the code bellow.

                                                                       #
import pandas_datareader as web
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
# Since is_list_like is moved to pandas.api.types just define is_list_like using the line above
                                                                       #

The code should run with no issues. The error should disappear as a result.

Solution 3 : edit the fred.py file located in the pandas-datareader folder located inside the pandas-datareader package directory

The third solution is to manually edit the fred.py file located in the pandas-datareader package directory.

First, you should navigate to the python dist-packages directory, you can find the location bellow

                                                                       #
/usr/local/lib/pythonX.X/dist-packages
# or
/usr/lib/pythonX.X/dist-packages 
# replace pythonX.X with your python version
                                                                       #

Find the folder called pandas-datareader and then the file called fred.py

remove from pandas.core.common import is_list_like and replace it with ( from pandas.api.types import is_list_like ).

It is very similar to what we did in the previous solution. Save the changes and voila, the error should be gone.

I hope the fix above fixed your problem, good luck with the scripts to come.

Summing-up : 

This is the end of our article, the error pandas datareader ImportError cannot import name is_list_like could be confusing but with a little bit of investigating the error could be solved easily , thank you for reading. To support us consider donating to our Kofi account above. Keep coding, keep learning and cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/