2

I'm trying to set up scikit-learn, but after installing numpy and scikit-learn (using pip) that's what I get when trying to imort sklearn:

import sklearn
RuntimeError: module compiled against API version 8 but this version of numpy is 7
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/sklearn/__init__.py", line 32, in <module>
  from .base import clone
File "/usr/local/lib/python2.7/site-packages/sklearn/base.py", line 10, in <module>
  from scipy import sparse
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/__init__.py", line 182, in <module>
from .csr import *
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/csr.py", line 15, in <module>
from .sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/sparsetools/__init__.py", line 5, in <module>
from .csr import *
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/sparsetools/csr.py", line 26, in <module>
_csr = swig_import_helper()
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/sparsetools/csr.py", line 22, in swig_import_helper
_mod = imp.load_module('_csr', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

Tried to reinstall things without success

smogg
  • 1,494
  • 3
  • 19
  • 27
  • 1
    It looks like you have the wrong version of numpy - are you positive you installed the correct one? – thegrinner Mar 07 '13 at 21:32
  • @thegrinner Well, I have version 7 while the traceback mentions version 8. But is there a numpy 1.8 out there? This http://sourceforge.net/projects/numpy/files/NumPy/ confirms that I have the newest one – smogg Mar 07 '13 at 21:36
  • 1
    Hmmm... this github issue suggets 1.7.0b2 should work: https://github.com/jsalvatier/scikits.bvp_solver/issues/2 I assume you grabbed 1.7.0? – thegrinner Mar 07 '13 at 21:41
  • Or perhaps it's related to this issue on macports where the system numpy is being prioritized over the new version: https://trac.macports.org/ticket/31891 – thegrinner Mar 07 '13 at 21:42
  • What happens if you print `sys.path()`? – thegrinner Mar 07 '13 at 21:44
  • @thegrinner Yup, installing from source 1.7.0b2 helped, thanks. Please add your answer so I can accept it – smogg Mar 07 '13 at 21:54
  • The minimum requirement is numpy 0.13, as you can see in the readme and the installation documentation. It probably was a problem of setting the correct path to the easy_installed numpy. – Andreas Mueller Mar 09 '13 at 11:41

1 Answers1

1

Looking at this issue on github, it sounds like it might require a specific version of numpy - they used 1.7.0b2.

thegrinner
  • 11,546
  • 5
  • 41
  • 64
  • This issue is not related to scikit-learn at all as far as I can tell. – Andreas Mueller Mar 09 '13 at 11:40
  • @AndreasMueller I think root cause might actually be related to [this issue](https://trac.macports.org/ticket/31891) where the wrong library version is being given priority and installing a specific version just happened to fix that. – thegrinner Mar 11 '13 at 12:06