0

I am trying to install scikit-learn and OpenCV onto my 64-bit Macbook in order to use them both from Python.

I've done the following:

 sudo port install py27-scikit-learn

That seemed to complete OK. But now if I open Python and try to import sklearn, I get an error:

python2.7
> import sklearn
ImportError: numpy.core.multiarray failed to import

I'm not sure how to debug this... can anyone suggest where to start? Incidentally, import numpy or import numpy.core.multiarray on their own in Python do not throw any errors.

UPDATE: it looks like an incorrect version of numpy might be the answer, but I'm not sure how to fix it.

UPDATE: Figured it out, had to delete an old version of numpy.

Community
  • 1
  • 1
Richard
  • 62,943
  • 126
  • 334
  • 542
  • 1
    You should post your solution as an answer and accept it. As a side-note I would strongly recommend using [virtual environments](http://docs.python-guide.org/en/latest/dev/virtualenvs.html) to deal with version issues like this. – ali_m Aug 21 '13 at 17:26
  • Unfortunately building scipy (another dependency of scikit-learn) from source can be complex on non-linux platforms (you need a fortran compiler and sometimes install missing dependencies such as blas and lapack). Hence using pre-built, platform specific distribution of scipy might still be easier. – ogrisel Aug 21 '13 at 17:32
  • @ogrisel: it's still possible to install numpy binaries into a virtualenv - see [this answer](http://stackoverflow.com/questions/6114115/windows-virtualenv-pip-numpy-problems-when-installing-numpy/6753898#6753898) – ali_m Aug 21 '13 at 18:19
  • 1
    Yes but scikit-learn will also need scipy and to build scipy in a venv you will need to install gfortran with brew and so on. Asking newcomers to build SciPy under OSX is not always the best path. Hopefully future version of scipy will come with wheel binary packages for OSX and that will make this much easier. – ogrisel Aug 21 '13 at 19:10
  • PLEASE don't mark this question as duplicate. The wording of the question, together with the applicable answer, is not duplicate. – Richard Aug 22 '13 at 14:49

0 Answers0