【发布时间】:2018-02-06 15:27:48
【问题描述】:
我是 python 新手,并试图在 Jupyter 笔记本中运行 this 示例。每当我跟随
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.api import SimpleExpSmoothing
它给了我以下错误
ImportError Traceback (most recent call last)
<ipython-input-5-a15788c08ca7> in <module>()
3 import pandas as pd
4 import matplotlib.pyplot as plt
----> 5 from statsmodels.tsa.api import SimpleExpSmoothing
ImportError: cannot import name 'SimpleExpSmoothing'
虽然,我已经安装了 statsmodels (0.8.0) by
pip install statsmodels
与其他软件包(numpy、pandas 等)一样。我检查了git,api 文件包含此方法,但我的 api 文件(通过 pip 获得)没有此方法。也许我没有通过 pip 获得 git 版本(似乎是最新版本)?我在 windows 上工作,我也在 mac OSX 上试过,结果是一样的。我试图对 git 文件中丢失的文件/代码进行复制/粘贴尝试(不是一个好方法),但这没有帮助。我会在这里感谢您的建议。
编辑
所以Jupyter的解决方案(感谢@user333700)是直接从git安装master分支
pip install git+https://github.com/statsmodels/statsmodels.git
我正在扩展我对 PyCharm 的问题,如何在 PyCharm 中添加一个 git 包?这个link 没有帮助。
【问题讨论】:
-
指数平滑仅在不久前合并,仅在 statsmodels master 中可用。您必须安装主版本才能使用它。
-
@user333700 非常感谢,
pip install git+https://github.com/statsmodels/statsmodels.git解决了 Jupyter 的问题。我现在想知道如何在 PyCharm 中安装 git 包?这个link 没有帮助。
标签: python git pycharm jupyter-notebook