ImportError: No module named statsmodels.api
13,471
Solution 1
On Ubuntu 12.04, statsmodels is installed through scikits.
Hence:
import scikits.statsmodels.api as sm
Solution 2
from statsmodels import api as sm
Related videos on Youtube
Author by
F.N.B
Updated on September 15, 2022Comments
-
F.N.B over 1 year
I'm new in python and have this problem. I have install Pandas, Numpy, Scipy, and I install Stats Models with apt-get install python-statsmodels, but when I try to use:
import statsmodels.api as sm
But I have this problem:
ImportError Traceback (most recent call last) <ipython-input-1-6030a6549dc0> in <module>() ----> 1 import statsmodels.api as sm ImportError: No module named statsmodels.api
Why??
-
F.N.B almost 11 yearsThe error is the same: ImportError: No module named statsmodels
-
RickyA almost 11 yearsTry 'import statsmodels'. If that fails it is not installed correctly. Try to see if it is present in the site-packages dir of your python install. Are you using virtualenv?
-
F.N.B almost 11 yearsNo, I don't use virtualenv. And when I try 'import statsmodels' the error continuous. where I see the site-packages?? Is in /usr/lib/python2.7??
-
RickyA almost 11 years
from distutils.sysconfig import get_python_lib print(get_python_lib())
seems to be:/usr/lib/python2.7/dist-packages
on ubuntu. -
RickyA almost 11 yearson Ubuntu it seems to be: /usr/local/lib/python2.7/dist-packages/
-
F.N.B almost 11 yearsStatsModels don't are in dist-packages, but I install with apt-get, I need install with pip?? or how i do to install in dist-packages?
-
RickyA almost 11 yearstry pip. that normally installs in dist-packages.
-
F.N.B almost 11 yearsI install with pip, but install in /usr/local/lib/python2.7/dist-packages an not in /usr/lib/python2.7/dist-packages, and the problem continuos, this is the problem?? how I say where do I install it?
-
RickyA almost 11 yearsThat is the problem, you cant tell tell it where to install. What you could try is copy all
statsmodels
stuff from/usr/local/lib/dist-packages
to/usr/lib/dist-packages
since they are using the same python version.