【问题标题】:Failing to install scikits.sparse - Clang error无法安装 scikits.sparse - Clang 错误
【发布时间】:2013-10-18 18:49:20
【问题描述】:

我在使用 django 时遇到以下错误:

Exception Type: ImportError
Exception Value:    No module named sparse

导入错误来自:

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

为了解决这个问题,我尝试通过以下方式为 scikit-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

我该如何解决这个问题?

谢谢。

【问题讨论】:

    标签: python scikit-learn installation clang sparse-matrix


    【解决方案1】:

    改变

    from sklearn.svm.sparse import LinearSVC
    

    到

    from sklearn.svm import LinearSVC
    

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

    【讨论】:

      【解决方案2】:

      适用于对安装 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/local/include 和 /usr/local/lib。

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

      cdef extern from "sparsesuite/cholmod.h":
      

      到

      cdef extern from "cholmod.h":
      

      然后尝试再次安装 scikits.sparse。应该可以。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-12-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-01
        • 2016-01-23
        • 2023-03-11
        • 2019-07-06
        • 2013-11-30
        相关资源
        最近更新 更多