Error compiling C code for python hmmlearn package
Question: I'm having some trouble getting the `hmmlearn` package to install properly (in
a virtual environment); it seems to have something to do with the underlying C
code. The package installs fine with `pip`, but when I try to import the core
class, I get an error:

    
    
    In [1]: import hmmlearn
    
    In [2]: from hmmlearn import hmm
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-2-8b8c029fb053> in <module>()
    ----> 1 from hmmlearn import hmm
    
    /export/hdi3/home/krono/envs/sd/lib/python2.7/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
    
    /export/hdi3/home/krono/envs/sd/lib/python2.7/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: /export/hdi3/home/krono/envs/sd/lib/python2.7/site-packages/hmmlearn/_hmmc.so: undefined symbol: npy_expl
    

I've been reading other questions on SO which seem to treat this, but [one
solution](http://stackoverflow.com/questions/30428278/undefined-symbols-in-
scipy-and-scikit-learn-on-redhat) (use Anaconda) won't work since `hmmlearn`
isn't included. It seems like the answer has something to do with compiling
the C code, but I'm not sure how to go about it. Any help would be much
appreciated!


Answer: I ran into the same issue a while ago and found the
[solution](http://stackoverflow.com/a/35123700/3846213) by trying everything
possible. For whatever reason in some cases `pip` skips building C-extensions,
when a package is saved into the cache directory. If you force `pip` to ignore
the cache, it always builds the package from scratch, so the solution is to
uninstall the package in the first place and then run `pip install --no-cache-
dir <package>`

