简体   繁体   中英

Unable to import statsmodels on jupyter notebook

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?

The module is statsmodels . See the documentation here .

So the correct way to call it is

import statsmodels.api as sm

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM