To solve ImportError: No module named statsmodels error follow below methods.
ERROR LOG
import statsmodels.api as sm
ImportError: No module named statsmodels.api
Contents
How to solve ImportError: No module named statsmodels ?
Refer the given methods to solve the issue.
Method 1:
You should not untar it to /usr/local/lib/python2.7/dist-packages
(you may use any temporary directory) since you may have used a different Python executable by mistake, such as /usr/bin/python
instead of the one corresponding to /usr/local/lib/python2.7
.
To install it, use pip according to the appropriate Python version, use python -V to check the version:
python -m pip install statsmodels
It would make it simple to upgrade and uninstall it. Install as a non-root user to avoid accidentally messing up the system python installation. Instead, you might use the –user or virtualenv options.
Method 2 :
pip install --upgrade --no-deps statsmodels
#using conda
conda install statsmodels
After that, restart your Jupyter notebook. If you get an error like “no module pasty,” stop your Jupyter notebook and try the command following on terminal.
pip install patsy
Hope the above solution works.
Also read :Error: No module named psycopg2.extensions