ImportError: No module named statsmodels.api - python

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

On Ubuntu 12.04, statsmodels is installed through scikits.
Hence:
import scikits.statsmodels.api as sm

from statsmodels import api as sm

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

It requires Stats module to be istalled...
Python command#
!pip3 install statsmodels
Reference#
https://pypi.org/project/statsmodels/

For the current version you could use a binary installer:
http://statsmodels.sourceforge.net/binaries/

Related

ModuleNotFoundError: No module named 'scipy.misc.pilutil'

I am not able to import scipy.misc.pilutil
Though I have pillow and scipy installed. I am able to import scipy.misc but can't use functions like imresize
from scipy.misc.pilutil import imresize
ModuleNotFoundError
Traceback (most recent call last)
<ipython-input-20-a7ba6cfb7450> in <module>()
----> 1 from scipy.misc.pilutil import imsave
ModuleNotFoundError: No module named 'scipy.misc.pilutil'
You get this error because you are using scipy v1.3.0 and imresize() is deprecated.
Also make sure you have Pillow installed.
See here: https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.imresize.html
"imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0."
Either downgrade to v1.2.x or use Pillow resize() instead: numpy.array(Image.fromarray(arr).resize()).
Check your scipy version. I had the same issue and after I've changed the scipy version to 1.1.0. the issue disappeared.
To check the scipy version in the terminal:
import scipy
scipy.version.full_version
The newer version of scipy has removed the imsave and many other functions such as resize, you can install older version of scipy with following:
pip install scipy==1.1.0

sklearn module not found in anaconda

I've been trying to import sklearn but it says that the module is not found.
my python, numpy, scipy and scikit versions are as follows as show in the conda list:
numpy 1.14.3 py36h9fa60d3_1
python 3.6.5 h0c2934d_0
scipy 1.1.0 py36h672f292_0
scikit-learn 0.19.1 py36h53aea1b_0
the error while trying to import sklearn is:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-f2461ba6e1e9> in <module>()
----> 1 from sklearn.family import model
ModuleNotFoundError: No module named 'sklearn.family'
I tried using
conda update scikit-learn
conda install scikit-learn
but I get the following results
All requested packages already installed.
how do I import sklearn then?
Although there is not skleran module, from sklearn import ... works well in PyCharm:
from sklearn.utils import resample
Try doing
conda install -c anaconda pip
pip install sklearn
AFAIK, there's no sklearn.family module. Have you tried importing other modules?
Say,
from sklearn.model_selection import TimeSeriesSplit
Does that work for you?

Failing to import numpy in Jupyter

First bear with me as I am relatively new to coding. I am trying to import numpy to Jupyter (localhost, webbased) using Python 3 and getting an error.
import numpy as np
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-0aa0b027fcb6> in <module>()
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
What should I do? Many thanks.
Maybe try download Anaconda and using that as your interpreter. Pretty sure that comes preinstalled with Numpy.
Or check that you are following the correct way for installing the python 3 version: think this might help: Install numpy on python3.3 - Install pip for python3
have you tried !pip install numpy in hte python Notebook cell?
I had the same problem despite correct version of Python and numpy on my Ubuntu. Then I tried something that worked in Google Colab:
!pip install numpy
After that I was able to import numpy without further complications.

Python scikit-learn Imputer import error

I have a silly question. I'm working on Pyhton using the Intellij IDE. I'm trying to import the below:
from sklearn.preprocessing import Imputer
However, I receive the following error:
Traceback (most recent call last): from sklearn.preprocessing import
Imputer
Can you please help with this?
Solution is to use the latest version of scikit-learn library. Install it by using the following command (sometimes sudo is required before pip):
pip (or, pip3) install scikit-learn==0.19.1
the = symbol must be replaced by ==

Anaconda cannot import scipy

Importing scipy in iPython gave me:
In [1]: import scipy
-----------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-4dc45f4c0083> in <module>()
----> 1 import scipy
/usr/local/lib/python2.7/site-packages/scipy/__init__.py in <module>()
/usr/local/lib/python2.7/site-packages/scipy/_lib/_ccallback.py in <module>()
ImportError: cannot import name _ccallback_c
In [2]:
Did a complete update of all the files of Anaconda
> conda update --all
and the error remains. Did a complete search on the web and there are similar problems but without solutions. Can you help me?
i am giving you two solutions which might work by my expereince
1. create a virtualenv and install the scipy package in that virtualenv and give path like this
import sys
sys.path.append('/home/shashi/.virtualenvs/venv/lib/python2.7/site-packages/')
import scipy
2.
Download the source code https://github.com/scipy/scipy/archive/v0.18.0-1.zipand unpack it. Open a command window in the folder where the setup.py of the module is located and type
scipy python setup.py install
It looks like scipy is not installed
conda install -c anaconda scipy
Try this and let us know if you receive the error again
Cheers!

Categories

Resources