Numpy.dtype is the wrong size, try recompiling

When importing pandas, I get the following error:

Numpy.dtype has the wrong size, try recompiling

I am running Python 2.7.5 with pandas 0.14.1 and Numpy 1.9.0. I tried to install older versions of both applications using major errors every time. I start when it comes to Python, so any help here would be greatly appreciated. :)

EDIT: Running OS X 10.9.4

EDIT 2: here is the link to the video in which I uninstall and reinstall Numpy + Pandas and then run the .py file: https://www.dropbox.com/s/sx9l288jijokrar/numpy%20issue.mov?dl=0

+13
python numpy pandas
Sep 26 '14 at 20:18
source share
4 answers

I have seen this error before, and it is usually related to pandas link to the old version of numpy. But reinstalling may not help if your python path still points to the old version of numpy.

When you install numpy through pip, pip will tell you where it was installed. Something like

 pip install numpy==1.9.2 Requirement already satisfied (use --upgrade to upgrade): numpy==1.9.2 in /Library/Python/2.7/site-packages Cleaning up... 

So you have the correct version of numpy installed. But when you enter python

 $ python Python 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> numpy.__file__ '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.pyc' >>> numpy.version.version '1.8.0rc1' 

Your path may point to a different number.

The easiest solution I found for this is to simply uninstall the unnecessary version of numpy (by moving it to the _bak folder for security)

 mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy_bak 

And now when I run python

 $ python Python 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> numpy.__file__ '/Library/Python/2.7/site-packages/numpy/__init__.pyc' >>> numpy.version.version '1.9.2' 

I have the version I want.

For more complex workflows, when different applications may require different versions of different packages, virtualenvs is a great way to go http://docs.python-guide.org/en/latest/dev/virtualenvs/ . But I think for your case, when you just want pandas and numpy to play well, this approach should work fine.

+19
Mar 28 '15 at 19:01
source share

I have the same error. I decided to remove the existing numpy and install again.

 pip uninstall numpy #it will remove older version of numpy on your computer pip install numpy #it will install recent version of numpy 

Actually, I don't know why this works. I just changed the numpy version.

+5
Mar 28 '16 at 8:11
source share

you should try updating your numpy to the last. it worked for me.

 pip install --upgrade numpy 
+2
Aug 21 '16 at 9:44
source share

I have had the same issue lately and fixed it:
1. Remove python
2. Install the latest version of python 2. In my case, I installed python-2.7.15. Link: https://www.python.org/ftp/python/2.7.15/python-2.7.15.amd64.msi
3. Install pandas and sklearn

Now I hope that your code will work properly.

0
Dec 07 '18 at 3:25
source share



All Articles