Unable to import statsmodels on jupyter notebook

Question:

I’ve installed statsmodels and it says "requirement already satisfied", but when I import it I get an error that the module doesn’t exist.

conda update -n base -c defaults conda
pip install statsmodels
import statsmodel.api as sm
import yfinance as yf
import matplotlib.pyplot as plt
import datetime as dt
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-9-07cc0a2ad076> in <module>
      2 import matplotlib.pyplot as plt
      3 import datetime as dt
----> 4 import statsmodel.api as sm

ModuleNotFoundError: No module named 'statsmodel'

What do I do?

Asked By: Vidushi

||

Answers:

The module is statsmodels. See the documentation here.

So the correct way to call it is

import statsmodels.api as sm
Answered By: TC Arlen

I tried to restart the Jupyter and it didnt work. My solution was to create another jupyter notebook and copy the code which worked. Maybe it’s not the best solution but it solves the problem.