You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

虚拟环境中import pandas_datareader报ImportError: cannot import name 'is_list_like'

Fixing ImportError: cannot import name 'is_list_like' with pandas_datareader

Hey there, let's get this error sorted out for you. The issue you're facing is a classic version mismatch between pandas and pandas_datareader:

What's causing the error?

In newer versions of pandas, the is_list_like utility function was moved from pandas.core.common to pandas.api.types. But the version of pandas_datareader installed in your virtual environment is still trying to import it from the old location, hence the ImportError.

Here are 3 ways to fix this:

  • Option 1: Upgrade pandas_datareader (Recommended)
    This is the simplest fix—just update pandas_datareader to a version that's compatible with your pandas installation. Run this command in your virtual environment:

    pip install --upgrade pandas_datareader
    

    After upgrading, try running your script again; the import should work without issues.

  • Option 2: Manually fix the import path in pandas_datareader
    If upgrading isn't an option (e.g., your Python 3.5 is too old for the latest pandas_datareader), you can edit the problematic file directly:

    1. Navigate to the fred.py file at this path: /home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/fred.py
    2. Open it with a text editor, and replace the first line:
      from pandas.core.common import is_list_like
      
      with:
      from pandas.api.types import is_list_like
      
    3. Save the file and re-run your script.
  • Option 3: Downgrade pandas (Not Recommended)
    As a last resort, you can roll back pandas to an older version where is_list_like still lives in pandas.core.common. Run:

    pip install pandas==0.23.4
    

    Note: This might cause compatibility issues with other parts of your code that rely on newer pandas features, so only use this if the first two options don't work.

Once you've tried one of these solutions, test your import code again—you should be able to import pandas_datareader without hitting the error.

内容的提问来源于stack exchange,提问作者Raj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:12:42