6

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
  • 1,539
  • 6
  • 23
  • 39

5 Answers5

3

On Ubuntu 12.04, statsmodels is installed through scikits.

Hence:

import scikits.statsmodels.api as sm
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
user2422635
  • 101
  • 1
  • 6
2
from statsmodels import api as sm
RickyA
  • 15,465
  • 5
  • 71
  • 95
  • The error is the same: ImportError: No module named statsmodels – F.N.B Jul 04 '13 at 14:12
  • 2
    Try '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? – RickyA Jul 04 '13 at 14:14
  • No, 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?? – F.N.B Jul 04 '13 at 14:26
  • `from distutils.sysconfig import get_python_lib print(get_python_lib())` seems to be: `/usr/lib/python2.7/dist-packages` on ubuntu. – RickyA Jul 04 '13 at 14:30
  • on Ubuntu it [seems](http://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory) to be: /usr/local/lib/python2.7/dist-packages/ – RickyA Jul 04 '13 at 14:32
  • StatsModels 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? – F.N.B Jul 04 '13 at 14:46
  • try pip. that normally installs in dist-packages. – RickyA Jul 04 '13 at 15:11
  • I 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? – F.N.B Jul 04 '13 at 16:03
  • That 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. – RickyA Jul 08 '13 at 10:55
0

I also got the same, error, and the following needs to be installed statsmodels - Statistical computation models for use with scipy.

Santosh
  • 1
  • 1
0

It requires Stats module to be istalled...

Python command# !pip3 install statsmodels

Reference# https://pypi.org/project/statsmodels/

-1

For the current version you could use a binary installer:

http://statsmodels.sourceforge.net/binaries/

user21988
  • 67
  • 1
  • 9