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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24122850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 04:02:24  来源:igfitidea点击:

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

pythonnumpypandas

提问by zelinka

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:

两次安装似乎都非常愉快,并且运行时没有任何错误(尽管有无数警告)。当我尝试使用 import 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?

如何修复此错误并使熊猫正确加载?

采纳答案by lolipop

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...

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

回答by Phani

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.

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

回答by simonemainardi

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.

这对我有用。

回答by Fabiano Francesconi

sudo pip install pandas
sudo easy_install --upgrade numpy

should also realign everything.

也应该重新调整一切。

回答by DH_35

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

回答by Raghoonandh

pip uninstall numpyuninstalls the old version of numpy

pip uninstall numpy卸载旧版本的 numpy

pip install numpyfinds and installs the latest version of numpy

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