pandas ValueError: numpy.dtype has the wrong size, try recompiling
Asked Answered
U

6

16

I took a new clean install of OSX 10.9.3 and installed pip, and then did

pip install pandas
pip install numpy

Both installs seemed to be perfectly happy, and ran without any errors (though there were a zillion warnings). When I tried to run a python script with import pandas, I got the following error:


    numpy.dtype has the wrong size, try recompiling Traceback (most recent call last): 
    File "./moen.py", line 7, in  import pandas File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 6, in  from . import hashtable, tslib, lib 
    File "numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:22331) 
    ValueError: numpy.dtype has the wrong size, try recompiling

How do I fix this error and get pandas to load properly?

Undershot answered 9/6, 2014 at 14:50 Comment(3)
Looks like a similar issue - #17710141Fetial
Did you figure out a way to get around this without downgrading pandas? I want to try out 0.14 version.Typography
It looks similar, but what's unique about this question (and my current issue) is that recompiling is pointless: unlike the other question, this one explicitly clarifies that we're installing from scratch, and this library still doesn't work. The "try recompiling" output is a red herring.Indicatory
M
24

You can install previous version of pandas.

pip uninstall numpy
pip uninstall pandas
pip install pandas==0.13.1

In my situation it solved problem...

Metencephalon answered 16/6, 2014 at 11:9 Comment(1)
What worked for me is #26068192Stilt
K
18
sudo pip install pandas
sudo easy_install --upgrade numpy

should also realign everything.

Kinsella answered 22/8, 2014 at 7:57 Comment(0)
T
5

Uninstall both numpy and pandas and try installing pandas from source.

pip uninstall numpy
pip uninstall pandas
git clone git://github.com/pydata/pandas.git
cd pandas
python setup.py install

This worked for me and I am now able to use the latest version of pandas.

Typography answered 20/6, 2014 at 5:16 Comment(0)
C
5

open your python, check the imported version of your numpy.

It is very likely that you have multiple numpy installed and python always grab the old one, just make sure to delete the old one would fix the problem.

>>> import numpy as np
>>> np.__version__
>>> np.__file__
#if numpy version <= 1.7 would have the error
#find the file and delete it from (np.__file__)

then install the latest numpy if you don't have it

Chlorenchyma answered 30/10, 2014 at 21:57 Comment(1)
This was causing my problem. When I ran pip freeze it printed out version 1.9.2, but when I opened up the python terminal and ran np.__version__ it was pointing to version 1.5. Thanks!Zionism
J
1

you can install pandas from its git repo without having to explicitly clone it

pip install git+https://github.com/pydata/pandas.git

that worked for me.

Jasmin answered 21/8, 2014 at 15:29 Comment(0)
J
1

pip uninstall numpy uninstalls the old version of numpy

pip install numpy finds and installs the latest version of numpy

Josiejosler answered 17/1, 2015 at 6:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.