1

I've been getting the following error with django:

Exception Type: ImportError
Exception Value:    No module named sparse

The importerror comes from:

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

To solve this I'm trying to install the sparse module for scikit-learn via the following:

sudo easy_install scikits.sparse

But I am getting this error:

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

How can I solve this problem?

Thanks.

4

2 回答 2

3

改变

from sklearn.svm.sparse import LinearSVC

from sklearn.svm import LinearSVC

忘记了scikits.sparse,这与 scikit-learn 无关。该sklearn.svm.sparse模块在几个版本前已从 scikit-learn 中删除。

于 2013-10-18T22:04:08.267 回答
0

对于任何对安装 scikits.sparse 特别感兴趣的人。我在 Mac OS X 10.9 中遇到了麻烦。问题与 setuptools 根据您是否安装了 Cython 和 Pyrex 做出假设有关。

一个解决方案,当然不是最好的解决方案(对我有用)是安装 Pyrex。对于 macports 用户:

sudo port install py27-pyrex

安装稀疏套件。

编辑 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/local/include/usr/local/lib

在scikits/sparse/cholmod.pyx文件中编辑以下行:

cdef extern from "sparsesuite/cholmod.h":

cdef extern from "cholmod.h":

然后尝试再次安装 scikits.sparse。应该管用。

于 2014-05-26T05:09:43.337 回答