pandas_datareader ImportError:无法导入名称string_types

时间:2017-08-07 04:19:57

标签: python python-2.7 pandas

import pandas_datareader as pdr
pdr.get_data_yahoo('AAPL')

我通过pip安装了pandas_datareader,但一切都成功了。

当我尝试运行一个简单的代码时,我得到了以下错误:

"C:\Users\<username>\Anaconda2\python.exe" 
"C:/Users/<username>/PycharmProjects/untitled2/Yahoo.py"

Traceback (most recent call last):

  File "C:/Users/<username>/PycharmProjects/untitled2/Yahoo.py", line 1, in <module>

import pandas_datareader as pdr

  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\__init__.py", line 3, in <module>
    from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo, get_data_enigma,  # noqa

  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\data.py", line 7, in <module>

    from pandas_datareader.google.daily import GoogleDailyReader
  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\google\daily.py", line 1, in <module>

    from pandas_datareader.base import _DailyBaseReader

  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas_datareader\base.py", line 7, in <module>

    import pandas.compat as compat
  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\__init__.py", line 25, in <module>
    from pandas.core.api import *

  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\core\api.py", line 14, in <module>

    from pandas.core.series import Series, TimeSeries

  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\core\series.py", line 35, in <module>

    from pandas.compat.scipy import scoreatpercentile as _quantile
  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\compat\scipy.py", line 5, in <module>

    import numpy as np

  File "C:\Users\<username>\Anaconda2\lib\site-packages\pandas\compat\numpy\__init__.py", line 6, in <module>

    from pandas.compat import string_types, string_and_binary_types
ImportError: cannot import name string_types

Process finished with exit code 1

我有Python 2.7版本和Windows 7 64位系统。

安装过程是否有问题?

1 个答案:

答案 0 :(得分:0)

conda版本问题。需要升级conda版本