版本升级为scikit-learn

时间:2015-11-20 16:08:24

标签: macos python-2.7 numpy scipy scikit-learn

我想对某些数据执行LDA,因此遵循此示例:

http://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_vs_lda.html#example-decomposition-plot-pca-vs-lda-py

然而,尝试:

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis

我收到了导入错误。嗯,也许这是一个新功能,我想。所以我通过conda更新scikit-learn从0.15.2到0.17。但现在我甚至无法导入sklearn:

    import sklearn
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "//anaconda/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
    from .base import clone
  File "//anaconda/lib/python2.7/site-packages/sklearn/base.py", line 9, in <module>
    from scipy import sparse
  File "//anaconda/lib/python2.7/site-packages/scipy/sparse/__init__.py", line 213, in <module>
    from .csr import *
  File "//anaconda/lib/python2.7/site-packages/scipy/sparse/csr.py", line 13, in <module>
    from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: numpy.core.multiarray failed to import

我尝试使用pip和conda更新numpy和scipy无济于事。然后,我通过以下方式尝试完全干净地重新安装anaconda:

rm -rf ~/anaconda

以及随后从http://docs.continuum.io/anaconda/install#anaconda-install

下载.pkg

我仍然得到同样的错误。这是我的操作系统和包装细节:

Mac OSX 10.5.2
bash-3.2$ conda -V
conda 3.18.6

scipy==0.16.0
numpy==1.9.1
scikit-learn==0.17

最后一个通过pip冻结,因为我无法导入它。我在这里疯了。任何帮助非常感谢。

1 个答案:

答案 0 :(得分:0)

尝试:

conda install numpy=1.10.1

我之前遇到过module compiled against API version a but this version of numpy is 9错误,这为我解决了。