我对 Python 3x 非常陌生,在 Mac 上运行。
目前使用金融 python 的 sentdex 教程,尝试运行以下脚本:
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(2000,1,1)
end = dt.datetime(2016,12,31)
df = web.DataReader('TSLA', 'yahoo', start, end)
print(df.head())
但是,这会返回以下错误消息:
Traceback (most recent call last):
File "F:\Downloads\Python Work\try figuring thigns out\finance\try.py", line 1, in <module>
import pandas_datareader.data as web
File "C:\Python36\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:\Python36\lib\site-packages\pandas_datareader\data.py", line 7, in <module>
from pandas_datareader.google.daily import GoogleDailyReader
File "C:\Python36\lib\site-packages\pandas_datareader\google\daily.py", line 1, in <module>
from pandas_datareader.base import _DailyBaseReader
File "C:\Python36\lib\site-packages\pandas_datareader\base.py", line 13, in <module>
from pandas_datareader._utils import (RemoteDataError, SymbolWarning,
File "C:\Python36\lib\site-packages\pandas_datareader\_utils.py", line 5, in <module>
from pandas.core.common import PandasError
ImportError: cannot import name 'PandasError'
我认为 panda-datareader 本身可能有问题,我已确保已将其升级到最新版本(pandas-datareader 0.3.0.post0)
我可以安装旧版本吗?我一直在使用 pip3 通过 mac 终端安装。
非常感谢您的帮助!