ImportError:无法导入名称'StringIO'

时间:2019-07-20 09:13:19

标签: python-3.x stringio pandas-datareader

我正在尝试通过代码从雅虎公司的股票中获取数据。 但是我在pandas_datareader.data上收到ImportError,说 ImportError:无法导入名称“ StringIO” 请帮忙 我对此很陌生...已经花费了4个小时,但无法解决。

我什至尝试过

import io 
from io import StringIO

仍然出现相同的错误.. !!

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



style.use('ggplot')
start = dt.datetime(2018,1,1)
end = dt.datetime(2018,12,31)

df = web.datareader('TSLA','yahoo',start,end)
print(df.head(5))

错误:-

Traceback (most recent call last):
  File "C:\Users\JAILANCHAL\Desktop\tut.py", line 5, in <module>
    import pandas_datareader.data as web 
  File "C:\Users\JAILANCHAL\AppData\Local\Programs\Python\Python35\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
    from .data import (DataReader, Options, get_components_yahoo,
  File "C:\Users\JAILANCHAL\AppData\Local\Programs\Python\Python35\lib\site-packages\pandas_datareader\data.py", line 7, in <module>
    from pandas_datareader.av.forex import AVForexReader
  File "C:\Users\JAILANCHAL\AppData\Local\Programs\Python\Python35\lib\site-packages\pandas_datareader\av\__init__.py", line 3, in <module>
    from pandas_datareader.base import _BaseReader
  File "C:\Users\JAILANCHAL\AppData\Local\Programs\Python\Python35\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 个答案:

没有答案