Error compiling C code for python hmmlearn package

旧巷老猫 提交于 2019-12-24 05:50:15

问题


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 (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!


回答1:


I ran into the same issue a while ago and found the solution 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>



来源:https://stackoverflow.com/questions/38575860/error-compiling-c-code-for-python-hmmlearn-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!