2013-10-18 48 views
1

我已經收到以下錯誤和Django:未按規定安裝scikits.sparse - 鏘錯誤

Exception Type: ImportError 
Exception Value: No module named sparse 

的導入錯誤來源於:

from sklearn.svm.sparse import LinearSVC 
from nltk.classify.scikitlearn import SklearnClassifier 

爲了解決這個問題,我想

sudo easy_install scikits.sparse 

但我收到此錯誤:通過以下安裝稀疏模塊scikit學習

no previously-included directories found matching 'doc/_build' 
warning: no previously-included files matching '*~' found anywhere in distribution 
warning: no previously-included files matching '*.so' found anywhere in distribution 
warning: no previously-included files matching '*.pyc' found anywhere in distribution 
clang: error: no such file or directory: 'scikits/sparse/cholmod.c' 
clang: error: no input files 
error: Setup script exited with error: command 'clang' failed with exit status 1 

我該如何解決這個問題?

謝謝。

回答

3

變化

from sklearn.svm.sparse import LinearSVC 

from sklearn.svm import LinearSVC 

,忘記scikits.sparse,其中有無關scikit學習。 sklearn.svm.sparse模塊已從scikit中刪除 - 在幾個版本之前學習。

+0

非常感謝! – yonatano

0

對於任何對安裝scikits.sparse特別感興趣的人。我在Mac OS X 10.9中遇到了麻煩。這個問題與setuptools根據你是否安裝了Cython和Pyrex來作出假設有關。

一個解決方案,當然不是最好的解決方案(對我有效)是安裝Pyrex。對於macports用戶:

sudo port install py27-pyrex 

安裝SparseSuite。

編輯setup.py文件,以便爲ext_modules值如下:

ext_modules = [ 
    Extension("scikits.sparse.cholmod", 
       ["scikits/sparse/cholmod.pyx"], 
       libraries=["cholmod"], 
       include_dirs=[np.get_include(), "path/to/sparsesuite/include"], 
       library_dirs=["path/to/sparsesuite/lib"] 
      ), 
    ] 

對我來說,和庫目錄中SparseSuite是USR /本地/包括在/ usr/local/lib

編輯在scikits /稀疏/ cholmod.pyx文件以下行:

cdef extern from "sparsesuite/cholmod.h": 

cdef extern from "cholmod.h": 

然後嘗試重新安裝scikits.sparse。應該管用。