简体   繁体   English

无法在 jupyter notebook 上导入 statsmodels

[英]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.我已经安装了statsmodels ,它说“要求已经满足”,但是当我导入它时,我收到一个错误,指出该模块不存在。

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 .该模块是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.我试图重新启动 Jupyter,但它没有用。 My solution was to create another jupyter notebook and copy the code which worked.我的解决方案是创建另一个 jupyter notebook 并复制有效的代码。 Maybe it's not the best solution but it solves the problem.也许这不是最好的解决方案,但它解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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