ImportError: No module named statsmodels.api
Asked Answered
D

5

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??

Daunt answered 4/7, 2013 at 13:43 Comment(0)
O
3

On Ubuntu 12.04, statsmodels is installed through scikits.

Hence:

import scikits.statsmodels.api as sm
Orosco answered 23/5, 2015 at 23:52 Comment(0)
H
2
from statsmodels import api as sm
Heliolatry answered 4/7, 2013 at 14:1 Comment(9)
The error is the same: ImportError: No module named statsmodelsDaunt
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?Heliolatry
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??Daunt
from distutils.sysconfig import get_python_lib print(get_python_lib()) seems to be: /usr/lib/python2.7/dist-packages on ubuntu.Heliolatry
on Ubuntu it seems to be: /usr/local/lib/python2.7/dist-packages/Heliolatry
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?Daunt
try pip. that normally installs in dist-packages.Heliolatry
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?Daunt
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.Heliolatry
K
0

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

Kook answered 24/1, 2020 at 12:1 Comment(0)
E
0

It requires Stats module to be istalled...

Python command# !pip3 install statsmodels

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

Epicenter answered 3/5, 2021 at 9:40 Comment(0)
M
-1

For the current version you could use a binary installer:

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

Matthus answered 4/7, 2013 at 22:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.