本文主要介绍Python中,使用pandas时执行import pandas_datareader报错(ImportError: cannot import name 'is_list_like')的原因及解决方法。

1、import pandas_datareader的出错提示

Python 3.6.5 (default, Apr  1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas_datareader
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/usr/local/lib/python3.6/dist-packages/pandas_datareader/fred.py", line 1, in <module>
from pandas.core.common import is_list_like
ImportError: cannot import name 'is_list_like'

2、出错原因及解决方法

1)原因

由于将is_list_like其移动到pandas.api.types导致的,解决些错误应该将pandas.core.common import is_list_likefrom pandas.api.types import is_list_like

2)解决方法

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

推荐文档

相关文档

大家感兴趣的内容

随机列表