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

时间:2022-04-30 15:51:57

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

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

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:

两个安装似乎都非常高兴,并且运行没有任何错误(尽管有很多警告)。当我尝试使用导入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

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

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

6 个解决方案

#1


23  

You can install previous version of pandas.

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

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

In my situation it solved problem...

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

#2


18  

sudo pip install pandas
sudo easy_install --upgrade numpy

should also realign everything.

还应该重新调整一切。

#3


5  

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

卸载numpy和pandas并尝试从源代码安装pandas。

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.

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

#4


5  

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

打开你的python,检查你的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.

很可能你安装了多个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__)

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

然后安装最新的numpy如果你没有它

#5


1  

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

你可以从它的git repo安装pandas,而不必显式克隆它

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

that worked for me.

这对我有用。

#6


1  

pip uninstall numpy uninstalls the old version of numpy

pip uninstall numpy卸载旧版本的numpy

pip install numpy finds and installs the latest version of numpy

pip install numpy查找并安装最新版本的numpy

#1


23  

You can install previous version of pandas.

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

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

In my situation it solved problem...

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

#2


18  

sudo pip install pandas
sudo easy_install --upgrade numpy

should also realign everything.

还应该重新调整一切。

#3


5  

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

卸载numpy和pandas并尝试从源代码安装pandas。

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.

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

#4


5  

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

打开你的python,检查你的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.

很可能你安装了多个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__)

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

然后安装最新的numpy如果你没有它

#5


1  

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

你可以从它的git repo安装pandas,而不必显式克隆它

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

that worked for me.

这对我有用。

#6


1  

pip uninstall numpy uninstalls the old version of numpy

pip uninstall numpy卸载旧版本的numpy

pip install numpy finds and installs the latest version of numpy

pip install numpy查找并安装最新版本的numpy