1
votes

I wanted to do LDA on some data and so followed this example:

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

however, on trying:

from sklearn.discriminant_analysis import LinearDiscriminantAnalysis

I got an import error. Huh, maybe this is a new function, I thought. So I updated scikit-learn via conda from 0.15.2 to 0.17. But now I can't even import 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

I tried updating numpy and scipy using both pip and conda to no avail. I then tried a complete clean re-install of anaconda by:

rm -rf ~/anaconda

and a subsequent download of the .pkg from http://docs.continuum.io/anaconda/install#anaconda-install

Still I get the same error. Here are my OS and package details:

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

The last of these via pip freeze since I can't import it. I'm going nuts here. Any help much appreciated.

1
Have you attempted conda update -all? To make sure all other dependencies are met. - Leb
Hi Leb, yes I tried that to no avail. Thanks though. - mattmcvicar

1 Answers

0
votes

Try:

conda install numpy=1.10.1

I've had that module compiled against API version a but this version of numpy is 9 error before, and this solved it for me.