PyCharm (1.5.4) and Pandas 0.6.0

I am using PyCharm (1.5.4) as my python IDE on MacOS 10.6.4. I am tinkering with some code to manipulate stock price data. As part of that I want to import price data from yahoo by using the DataReader function that comes with Pandas 0.6.0. The code is as follow:

http://www.statalgo.com/2011/09/08/pandas-getting-financial-data-from-yahoo-fred-etc/

from pandas import ols, DataFrame
from pandas.stats.moments import rolling_std
from pandas.io.data import DataReader
import datetime

sp500 = DataReader("^GSPC", "yahoo", start=datetime.datetime(1990, 1, 1))
sp500_returns = sp500["adj clos"].shift(-250)/sp500["adj clos"] - 1

gdp = DataReader("GDP", "fred", start=datetime.datetime(1990, 1, 1))["value"]
gdp_returns = (gdp/gdp.shift(1) - 1)
gdp_std = rolling_std(gdp_returns, 10)
gdp_standard = gdp_returns / gdp_std

gdp_on_sp = ols(y=sp500_returns, x=DataFrame({"gdp": gdp_standard}))

sp500.plot()
gdp.plot()

When I run the code I get the following error:

Traceback (most recent call last):
  File "/Users/MyName/PycharmProjects/test/mytest", line 3, in <module>
    from pandas.io.data import DataReader
ImportError: No module named data

I see that PyCharm does not know how to unresolve the reference 'data'.

My python paths are set as follows:

import sys
from pprint import pprint as pp
pp(sys.path)

['/private/var/folders/st/stQUFIfOG28bmpY9dCspTk+++TI/-Tmp-',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/scikits.statsmodels-0.3.1-py2.7.egg',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python27.zip',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/plat-darwin',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/plat-mac',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/lib-tk',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/lib-old',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/lib-dynload',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages',
 '/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/site-packages/PIL']

What is puzzling is that PyCharm can resolve pandas.stats.moments but can't resolve pandas.io.data. I checked that both directories have the __init__.py file (the files are blank).

At this point I am not sure how to move forward. Greatly appreciate the help.

UPDATE:

$ cat __egginst__.txt 
# egginst metadata
egg_name = 'pandas-0.3.0-3.egg'
prefix = '/Library/Frameworks/EPD64.framework/Versions/7.1'
installed_size = 1454562
rel_files = [
'EGG-INFO/pandas/__egginst__.txt',
'lib/python2.7/site-packages/pandas-0.3.0-3.egg-info',

Seems like deleting PyCharm's python interpreter configuration and re-configuring solved the problem. Strange... but fixed

链接地址: http://www.djcxy.com/p/56476.html

上一篇: 加密和解密错误0x0407106B使用OpenSSL

下一篇: PyCharm(1.5.4)和熊猫0.6.0