Statsmodels: Fail gracefully when extensions are not built

Created on 8 May 2013  路  6Comments  路  Source: statsmodels/statsmodels

Until d5ed746752ed323208171a21d104e75fc287de48 , it was possible to use statsmodels from git without compiling the extensions, now it's not.

As suggested in https://github.com/statsmodels/statsmodels/pull/820 , the error message could be slightly nicer than:

In [1]: from statsmodels import api as sm
/usr/lib/python2.7/dist-packages/nose/plugins/manager.py:405: UserWarning: Module statsmodels was already imported from /home/pietro/nobackup/repo/statsmodels/statsmodels/__init__.pyc, but /usr/lib/pymodules/python2.7 is being added to sys.path
  import pkg_resources
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-39a064898d02> in <module>()
----> 1 from statsmodels import api as sm

/home/pietro/nobackup/repo/statsmodels/statsmodels/api.py in <module>()
      9 from .discrete.discrete_model import (Poisson, Logit, Probit, MNLogit,
     10                                       NegativeBinomial)
---> 11 from .tsa import api as tsa
     12 from .nonparametric import api as nonparametric
     13 import distributions

/home/pietro/nobackup/repo/statsmodels/statsmodels/tsa/api.py in <module>()
----> 1 from .ar_model import AR
      2 from .arima_model import ARMA, ARIMA
      3 import vector_ar as var
      4 from .vector_ar.var_model import VAR
      5 from .vector_ar.svar_model import SVAR

/home/pietro/nobackup/repo/statsmodels/statsmodels/tsa/ar_model.py in <module>()
     16 from statsmodels.tools.numdiff import (approx_fprime, approx_hess,
     17         approx_hess_cs)
---> 18 from statsmodels.tsa.kalmanf.kalmanfilter import KalmanFilter
     19 import statsmodels.base.wrapper as wrap
     20 from statsmodels.tsa.vector_ar import util

/home/pietro/nobackup/repo/statsmodels/statsmodels/tsa/kalmanf/__init__.py in <module>()
----> 1 from kalmanfilter import KalmanFilter

/home/pietro/nobackup/repo/statsmodels/statsmodels/tsa/kalmanf/kalmanfilter.py in <module>()
     30 from numpy.linalg import inv, pinv
     31 from statsmodels.tools.tools import chain_dot
---> 32 from . import kalman_loglike
     33 
     34 #Fast filtering and smoothing for multivariate state space models

ImportError: cannot import name kalman_loglike

Most helpful comment

Oh. Yes, you'll need to do a setup.py build_ext --inplace in that case. I'm not sure we want to add try/except everywhere to account for this case.

All 6 comments

Do you have Cython installed? What OS are you on?

Yes, I have Cython installed. I am on Debian wheezy.

But notice I did _not_ try to install in any way. I just tried, as I used to, to directly use statsmodels from the git repo (through local.pth). If I run the setup.py everything works great.
I opened this issue only because (I think I was suggested that) a message saying "please install so that extensions will be built" is nicer.

Oh. Yes, you'll need to do a setup.py build_ext --inplace in that case. I'm not sure we want to add try/except everywhere to account for this case.

OK, so no bug! Notice you may want to update the INSTALL.txt file, "Optional Dependencies" section.

Thanks, will do. Thought I caught all of these.

thank you so so so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ksomemo picture ksomemo  路  5Comments

josef-pkt picture josef-pkt  路  5Comments

ChenChingChih picture ChenChingChih  路  3Comments

emilmirzayev picture emilmirzayev  路  5Comments

samosun picture samosun  路  4Comments