pandas ValueError:numpy.dtype的大小错误,请尝试重新编译

zel*_*nka 16 python numpy pandas

我采用了新的OSX 10.9.3全新安装并安装了pip,然后做了

pip install pandas
pip install numpy

两个安装似乎都非常高兴,并且运行没有任何错误(尽管有很多警告).当我尝试使用导入pandas运行python脚本时,我收到以下错误:


    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

如何修复此错误并正确加载pandas?

小智 23

您可以安装以前版本的pandas.

pip uninstall numpy
pip uninstall pandas
pip install pandas==0.13.1
Run Code Online (Sandbox Code Playgroud)

在我的情况下,它解决了问题......


Fab*_*oni 18

sudo pip install pandas
sudo easy_install --upgrade numpy
Run Code Online (Sandbox Code Playgroud)

还应重新调整一切.


Pha*_*ani 5

卸载numpy和pandas,然后尝试从源代码安装pandas.

pip uninstall numpy
pip uninstall pandas
git clone git://github.com/pydata/pandas.git
cd pandas
python setup.py install
Run Code Online (Sandbox Code Playgroud)

这对我有用,我现在可以使用最新版本的熊猫了.


小智 5

打开你的python,检查你的numpy的导入版本.

很可能你安装了多个numpy并且python总是抓住旧的,只要确保删除旧的就会解决问题.

>>> 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__)
Run Code Online (Sandbox Code Playgroud)

如果没有,请安装最新的numpy