简体   繁体   English

如何解决 Jupyter Notebook 中 No module named 'hmmlearn' 错误

[英]How to resolve No module named 'hmmlearn' error in Jupyter Notebook

I'm new to hmmlearn and am trying to use the Jupyter Notebook to work through this Gaussian HMM of stock data example .我是 hmmlearn 的新手,正在尝试使用 Jupyter Notebook 来完成这个高斯 HMM 股票数据示例 However, when I run the following code, I get an error.但是,当我运行以下代码时,出现错误。

from __future__ import print_function

import datetime

import numpy as np
from matplotlib import cm, pyplot as plt
from matplotlib.dates import YearLocator, MonthLocator
try:
    from matplotlib.finance import quotes_historical_yahoo_ochl
except ImportError:
    # For Matplotlib prior to 1.5.
    from matplotlib.finance import (
        quotes_historical_yahoo as quotes_historical_yahoo_ochl
    )

from hmmlearn.hmm import GaussianHMM


print(__doc__)

The error is as follows:错误如下:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-02bbde14d4d4> in <module>()
     14     )
     15 
---> 16 from hmmlearn.hmm import GaussianHMM
     17 
     18 

ModuleNotFoundError: No module named 'hmmlearn'

I have spent a while searching the Inte.net and trying to find out why this is happening.我花了一段时间搜索 Inte.net 并试图找出发生这种情况的原因。 I've ensured that I've downloaded the dependencies (scikit-learn, numpy and scipy), and I've run pip install -U --user hmmlearn , both via the Windows cmd and as mentioned here .我已经确保我已经下载了依赖项(scikit-learn、numpy 和 scipy),并且我已经运行pip install -U --user hmmlearn ,两者都是通过 Windows cmd 和此处提到的。 However, I keep getting the same error.但是,我不断收到相同的错误。 I'm not sure if it may be something to do with the location of the different packages on my computer (I'm using Windows).我不确定这是否与我计算机上不同软件包的位置有关(我使用的是 Windows)。

Does anyone have suggestions on what I could try to solve this?有人对我可以尝试解决这个问题有什么建议吗? (My main aim is just to be able to get set up with hmmlearn so that I can start using it to explore HMMs.) (我的主要目标只是能够使用 hmmlearn 进行设置,以便我可以开始使用它来探索 HMM。)

This page provides 32- and 64-bit Windows binaries of many scientific open-source extension packages for the official CPython distribution of the Python programming language.页面为 Python 编程语言的官方 CPython 发行版提供了许多科学开源扩展包的 32 位和 64 位Windows二进制文件。

Select the appropriate file according to your system requirements.根据您的系统要求选择适当的文件。 (For me, it's python 3.7 and windows 64 bit) (对我来说,它是 python 3.7 和 windows 64 位)

After you downloaded this, open command prompt in the same folder with .whl file and type:下载后,在同一个文件夹中打开命令提示符与 .whl 文件并键入:

pip install hmmlearn-0.2.1-cp37-cp37m-win_amd64.whl

Then you can use hmmlearn in the Jupyter Notebook like that:然后你可以像这样在Jupyter Notebook 中使用hmmlearn

import hmmlearn
# Or 
from hmmlearn import hmm

I have tried to run 'pip install hmmlearn' directly in the notebook cell.我试图直接在笔记本单元中运行“pip install hmmlearn”。 After that I restarted the kernel and it worked for me.之后我重新启动了 kernel,它对我有用。 Try to see if it works for you.试试看它是否适合你。

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

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