gpt4 book ai didi

python - import pandas_datareader 给出 ImportError : cannot import name 'is_list_like'

转载 作者:IT老高 更新时间:2023-10-28 20:24:17 25 4
gpt4 key购买 nike

我在虚拟环境中工作。我可以在没有任何错误的情况下导入和使用 Pandas ,但是当我尝试 import pandas_datareader

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import datetime as dt
from matplotlib import style
import pandas_datareader as web

它给出了以下错误-

Traceback (most recent call last):
File "stock.py", line 6, in <module>
import pandas_datareader as web
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/home/xxxxx/django-apps/env/lib/python3.5/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'
(env) xxxxx@xxxxx-yyyyy ~/pyt $ python stock.py
Traceback (most recent call last):
File "stock.py", line 6, in <module>
import pandas_datareader
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "/home/xxxxx/django-apps/env/lib/python3.5/site-packages/pandas_datareader/data.py", line 14, in <module>
from pandas_datareader.fred import FredReader
File "/home/xxxxx/django-apps/env/lib/python3.5/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'

最佳答案

在本地更改任何文件并绕过包管理器 (pip) 的版本控制的解决方案是像这样定义 is_list_like:

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

就在之前

import pandas_datareader as web

此外,此问题将在 pandas_datareader 0.7.0 版本中修复。

关于python - import pandas_datareader 给出 ImportError : cannot import name 'is_list_like' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50394873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com