Pregunta

I have: statsmodels 0.5.0 (formally known as scikits.statsmodels) pandas 0.12.0. (all installed from source)

I get this error:

  File "/home/username/.local/python27/lib/python2.7/site-packages/pandas-0.12.0-py2.7-linux-x86_64.egg/pandas/stats/ols.py", line 53, in __init__
import scikits.statsmodels.api as sm
ImportError: No module named scikits.statsmodels.api

Why is pandas still looking for scikits.statsmodels? Should I install an old version of scikits.statsmodels parallel to statsmodels 0.5.0?

¿Fue útil?

Solución

Version 0.12 first tries to import the statsmodels library and only if it fails, pandas fall back to the scikits module. Here is the piece of code that tries to do that:

try:
    import statsmodels.api as sm
except ImportError:
    import scikits.statsmodels.api as sm

If you type in the interpreter:

import statsmodels.api as sm

What error do you get?

Otros consejos

You are missing the right package.

Just run:

sudo pip install statsmodels

So, I encountered this problem and the reason was statsmodels has a dependency on patsy.

try:
    import statsmodels.api as sm
except ImportError:
   import scikits.statsmodels.api as sm

When importing statsmodels, not having patsy also throws an ImportError. Running

easy_install patsy

was a fix for this. Not sure why, but pip installed statsmodels without realizing patsy was a dependency.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top