我一直在使用django收到以下错误:
Exception Type: ImportError
Exception Value: No module named sparse
importerror来自:
from sklearn.svm.sparse import LinearSVC
from nltk.classify.scikitlearn import SklearnClassifier
要解决这个问题,我正尝试通过以下方法安装sparse-learn的稀疏模块:
sudo easy_install scikits.sparse
但是我收到了这个错误:
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
我该如何解决这个问题?
感谢。
答案 0 :(得分:3)
更改
from sklearn.svm.sparse import LinearSVC
到
from sklearn.svm import LinearSVC
并忘记scikits.sparse
,这与scikit-learn无关。 sklearn.svm.sparse
模块已从scikit中删除 - 在几个版本之前学习。
答案 1 :(得分: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的include和library目录是 usr / local / include 和 / usr / local / lib 。
编辑 scikits / sparse / cholmod.pyx 文件中的以下行:
cdef extern from "sparsesuite/cholmod.h":
到
cdef extern from "cholmod.h":
然后尝试再次安装scikits.sparse。应该工作。