为什么Pandas datareader在从脚本调用时不起作用?
如果我逐行在python shell中输入它(见下文),它就像宣传的那样工作。但当我把它作为一个脚本运行时,它会崩溃; “python3 script.py”(下面的错误):
import pandas_datareader.data as web
import datetime
start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2013, 1, 27)
f = web.DataReader("F", 'yahoo-dividends', start, end)
f
File "pandas.py", line 1, in <module>
import pandas_datareader.data as web
File "/usr/local/lib/python3.4/dist-packages/pandas_datareader-0.2.1-py3.4.egg/pandas_datareader/__init__.py", line 3, in <module>
from .data import (get_components_yahoo, get_data_famafrench, get_data_google, get_data_yahoo,
File "/usr/local/lib/python3.4/dist-packages/pandas_datareader-0.2.1-py3.4.egg/pandas_datareader/data.py", line 7, in <module>
from pandas_datareader.google.daily import GoogleDailyReader
File "/usr/local/lib/python3.4/dist-packages/pandas_datareader-0.2.1-py3.4.egg/pandas_datareader/google/daily.py", line 1, in <module>
from pandas_datareader.base import _DailyBaseReader
File "/usr/local/lib/python3.4/dist-packages/pandas_datareader-0.2.1-py3.4.egg/pandas_datareader/base.py", line 9, in <module>
from pandas import to_datetime
File "/home/pi/python/pandas.py", line 1, in <module>
import pandas_datareader.data as web
AttributeError: 'module' object has no attribute 'data'
答案 0 :(得分:0)