0

Every time I try to use a class from sklearn I get the following error:

  File "/Library/Python/2.7/site-packages/sklearn/__init__.py", line 57, in <module>
    from .base import clone
  File "/Library/Python/2.7/site-packages/sklearn/base.py", line 11, in <module>
    from .utils.fixes import signature
  File "/Library/Python/2.7/site-packages/sklearn/utils/__init__.py", line 10, in <module>
    from .murmurhash import murmurhash3_32
  File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling

I've tried to uninstall numpy, scikit, sklearn and reinstall it but it hasn't helped. I've OSX as an operating system. Here are the versions of the packages I'm using:

python 2.7.10

    numpy:          1.11.0
    pandas:         0.18.1
    scipy:          0.17.1
    scikit-learn:   0.17.1
    sklearn:        0.0 (which is weird but correct: https://pypi.python.org/pypi/sklearn/)

Upgrading every package to the newest version doesn't work. Do you have any idea what I could do about this? Maybe downgrading some package?

There are a lot of questions like mine on the internet. However, none of the suggested installs/uninstalls fixed my problem. It must be something version-specific.

ndrizza
  • 3,285
  • 6
  • 27
  • 41
  • How did you install these packages? – ali_m May 13 '16 at 19:14
  • Using pip. Is that all you want to know? Do you want to know more about the order? - I can't really remember. As long as there were no required packages I just installed them. Should I respect some order? – ndrizza May 13 '16 at 19:16
  • Uninstall `scikit-learn` followed by `pip install -U scikit-learn==0.16.1` and see if the issue is fixed. – Nickil Maveli May 13 '16 at 19:19
  • No unfortunately not. I'm getting the same error. – ndrizza May 13 '16 at 19:28
  • Maybe, it's the older installation of `numpy` which is causing this to happen. You could try `print numpy.__version__` and see what is the actual version being used. – Nickil Maveli May 13 '16 at 19:32
  • What I get is: 1.8.0rc1. What does this mean? Is it using an older version? – ndrizza May 13 '16 at 19:43
  • Unfortunately, Yes. Remedy would be to go to `../site-packages` directory and delete the numpy folder(or have a backup somewhere else) followed by `pip install numpy==1.11.0`.This should solve it. – Nickil Maveli May 13 '16 at 19:50
  • I did that and I still get the same error and I still get the same version number for numpy. I really don't know what to do about it. – ndrizza May 13 '16 at 20:04
  • 2
    There is a similar issue faced over here: http://stackoverflow.com/questions/26067692/numpy-dtype-has-the-wrong-size-try-recompiling/29321298#29321298 – Nickil Maveli May 13 '16 at 20:10
  • Thank you very much @NickilMaveli ! That solved the problem. Somehow everytime I imported numpy it imported the numpy of the system's python distribution (even tough I'm not using the system's python). I really can't explain why it linked to that one. However, now everything works! Thanks! – ndrizza May 13 '16 at 20:57
  • No worries. Glad you finally managed to fix it. – Nickil Maveli May 13 '16 at 21:03

0 Answers0