简体   繁体   English

为python hmmlearn软件包编译C代码时出错

[英]Error compiling C code for python hmmlearn package

I'm having some trouble getting the hmmlearn package to install properly (in a virtual environment); 我在使hmmlearn软件包正确安装(在虚拟环境中)时遇到一些麻烦; it seems to have something to do with the underlying C code. 它似乎与基础C代码有关。 The package installs fine with pip , but when I try to import the core class, I get an error: 该软件包可以通过pip很好地安装,但是当我尝试导入核心类时,出现错误:

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. 我一直在阅读关于SO的其他问题,这些问题似乎可以解决此问题,但是一种解决方案 (使用Anaconda)将无法使用,因为hmmlearn不包括hmmlearn It seems like the answer has something to do with compiling the C code, but I'm not sure how to go about it. 似乎答案与编译C代码有关,但是我不确定如何进行。 Any help would be much appreciated! 任何帮助将非常感激!

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. 在某些情况下,将软件包保存到缓存目录中时,由于某些原因, pip跳过构建C扩展名。 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> 如果强制pip忽略缓存,它将始终从头开始构建软件包,因此解决方案是首先卸载软件包,然后运行pip install --no-cache-dir <package>

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

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