我想对一些数据进行LDA,所以遵循了这个例子:
http://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_vs_lda.html#example-分解图pca与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
以及随后从中下载的.pkghttp://docs.continuum.io/anaconda/install#anaconda-安装
但我还是犯了同样的错误。以下是我的操作系统和软件包详细信息:
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冻结,因为我不能进口。我在这里疯了。非常感谢您的帮助。
尝试:
conda install numpy=1.10.1
我以前遇到过module compiled against API version a but this version of numpy is 9
错误,这帮我解决了这个问题。