python版本为3.6.6,pandas_datareader版本为0.7.0
当我导入pandas_datareader时,发生如下错误。
C:\PycharmProjects\Demo\venv\Scripts\python.exe C:/PycharmProjects/Demo/stock.py
Traceback (most recent call last):
File "C:/PycharmProjects/Demo/stock.py", line 3, in <module>
import pandas_datareader as wb
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
from .data import (DataReader, Options, get_components_yahoo,
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\data.py", line 7, in <module>
from pandas_datareader.av.forex import AVForexReader
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\av\__init__.py", line 3, in <module>
from pandas_datareader.base import _BaseReader
File "C:\PycharmProjects\Demo\venv\lib\site-packages\pandas_datareader\base.py", line 11, in <module>
from pandas.compat import StringIO, bytes_to_str
ImportError: cannot import name 'StringIO'
有人可以帮我吗?
答案 0 :(得分:0)
我在使用Python3.6和Python3.7时遇到了同样的问题
已降级,并且在Python2.7上运行良好 另外,在上面看到了Python3.5可以工作的注释。
答案 1 :(得分:0)
实际上,问题是pandas 0.25.0删除了pandas.compat。 所以回到0.24.2
pip install "pandas<0.25.0"
或
pipenv install "pandas<0.25.0"
答案 2 :(得分:0)
问题是pandas 0.25.0删除了pandas.compat。所以回到0.24.2
pip install "pandas<0.25.0"
或
pipenv install "pandas<0.25.0"