4

I'm new to hmmlearn and am trying to use the Jupyter Notebook to work through this Gaussian HMM of stock data example. 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 Internet and trying to find out why this is happening. 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. 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).

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.)

2 Answers2

2

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.

Select the appropriate file according to your system requirements. (For me, it's python 3.7 and windows 64 bit)

After you downloaded this, open command prompt in the same folder with .whl file and type:

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

Then you can use hmmlearn in the Jupyter Notebook like that:

import hmmlearn
# Or 
from hmmlearn import hmm
Orhan Solak
  • 789
  • 2
  • 15
  • 30
1

I have tried to run 'pip install hmmlearn' directly in the notebook cell. After that I restarted the kernel and it worked for me. Try to see if it works for you.