1

So I am trying to get hmmlearn working in Jupyter, and I have come across an error while installing Hmmlearn using pip. I have tried this solution, but it didn't work.

It seems to me that pip does install the _hmmc file, but it does so incorrect. instead it has the name

_hmmc.cp35-win_amd64

and the file extesion is .PYD, instead of .c

When I run the code to import it, I get this error :

    ImportError                               Traceback (most recent call last)
    <ipython-input-1-dee84c3d5ff9> in <module>()
          7 import os
          8 from pyAudioAnalysis import audioBasicIO as aB
    ----> 9 from pyAudioAnalysis import audioAnalysis as aA

    C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioAnalysis.py in <module>()
         15 import audioFeatureExtraction as aF
         16 import audioTrainTest as aT
   --->  17 import audioSegmentation as aS
         18 import audioVisualization as aV
         19 import audioBasicIO

    C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioSegmentation.py in <module>()
         16 import sklearn
         17 import sklearn.cluster
    ---> 18 import hmmlearn.hmm
         19 import cPickle
         20 import glob

    C:\Users\gover_000\Anaconda3\envs\python2\lib\site-packages\hmmlearn\hmm.py in <module>()
         19 from sklearn.utils import check_random_state
         20 
    ---> 21 from .base import _BaseHMM
         22 from .utils import iter_from_X_lengths, normalize
         23 

    C:\Users\gover_000\Anaconda3\envs\python2\lib\site-packages\hmmlearn\base.py in <module>()
         11 from sklearn.utils.validation import check_is_fitted
         12 
    ---> 13 from . import _hmmc
         14 from .utils import normalize, log_normalize, iter_from_X_lengths
         15 

    ImportError: cannot import name _hmmc 

I don't know why pip just doesn't install it correctly, even when I tried to use --no-cache-dir

Edit: So i figured out what the problem was. my active python enviroment was python 3.5, as i was manually transferring the installed files to my enviroment, it failed because i had the wrong version. I had to change my active python enviroment: using activate <my_enviroment name> after that i could just use pip to install it again and it worked this time.

Anil_M
  • 10,893
  • 6
  • 47
  • 74

3 Answers3

0

Looking at your error message I guess that you have downloaded the hmmlearn package from GIT. Have you tried using a wheel (*.whl) file instead? You can download one from here. Check out which version fits your python installation.

Then use:

pip install <the_wheel_that_corresponds_to_your_python_version>.whl

Hope it helps.

Ricardo Alejos
  • 402
  • 4
  • 9
  • okay I downloaded the package, and ran `pip install Requirement 'hmmlearn-0.2.0-cp27-cp27m-win_amd64.whl' looks like a filename, but the file does not exist hmmlearn-0.2.0-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform. C:\Users\gover_000> – Govert Jaap Den Boef Oct 12 '16 at 14:22
  • edit, okay i downloaded the package and ran `pip install hmmlearn-0.2.0-cp27-cp27m-win_amd64.whl ` and it gave me this error : Requirement 'hmmlearn-0.2.0-cp27-cp27m-win_amd64.whl' looks like a filename, but the file does not exist hmmlearn-0.2.0-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform. – Govert Jaap Den Boef Oct 12 '16 at 14:24
  • Hello there. I see you tried to download a version of hmmlearn that is built to work with Python 2.7 (cp27), while in your original post I see that you were trying to install the version for Python 3.5 (cp35) - both in their 64b versions. Maybe you'd like to give a try to the wheel that corresponds to the cp35 build for 64b. – Ricardo Alejos Oct 13 '16 at 01:14
  • indeed, i think there might a problem with the versions. Only I want to get it working in python 2.7, but my root enviroment in conda is python 3.5 so if i use pip it will automatically install a 3.5 version. – Govert Jaap Den Boef Oct 13 '16 at 08:02
0

So i figured out what the problem was. my active python enviroment was python 3.5, as i was manually transferring the installed files to my enviroment, it failed because i had the wrong version. I had to change my active python enviroment: using activate <my_enviroment_name> after that i could just use pip to install it again and it worked this time.

0

not sure if it could be helpful to anyone but I installed hmmlearn as follows in my Jupyter Lab:

import sys
!{sys.executable} -m pip install hmmlearn