Numpy.dtype的大小错误,请尝试重新编译 [英] Numpy.dtype has the wrong size, try recompiling

查看:71
本文介绍了Numpy.dtype的大小错误,请尝试重新编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导入熊猫时,会出现以下错误:

When importing pandas I would get the following error:

Numpy.dtype has the wrong size, try recompiling

我正在运行Python 2.7.5,Pandas 0.14.1和Numpy 1.9.0.我尝试使用pip安装两种版本的旧版本,每次都会出现重大错误.我是Python的初学者,因此这里的任何帮助将不胜感激. :)

I am running Python 2.7.5, with Pandas 0.14.1, and Numpy 1.9.0. I have tried installing older versions of both using pip, with major errors every time. I am a beginner when it comes to Python so any help here would be much appreciated. :)

运行OS X 10.9.4

running OS X 10.9.4

这是指向我卸载和重新安装Numpy + Pandas,然后运行.py文件的视频的链接:

EDIT 2: here is a link to a video of me uninstalling and reinstalling Numpy + Pandas, and then running a .py file: https://www.dropbox.com/s/sx9l288jijokrar/numpy%20issue.mov?dl=0

推荐答案

我以前见过此错误,它通常与引用旧版本numpy的熊猫有关.但是,如果您的python路径仍然指向numpy的旧版本,则重新安装可能无济于事.

I've seen this error before and it typically does have to do with pandas referencing an old version of numpy. But reinstalling may not help if your python path is still pointing to an old version of numpy.

通过pip安装numpy时,pip会告诉您它的安装位置.像

When you install numpy via 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...

因此您已安装了正确版本的numpy.但是当您进入python

So you have the correct version of numpy installed. But when you go into 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'

您的路径可能指向另一个numpy.

Your path might be pointing at a different numpy.

为此,我找到的最简单的解决方案就是删除不需要的numpy版本(出于安全考虑将其移动到_bak文件夹中)

Easiest solution I've found for this is simply to remove the unwanted version of numpy (moving it to a _bak folder for safety)

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

现在,当我启动python

And now when I start 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've got the version I want.

对于更复杂的工作流(其中不同的应用程序可能需要不同版本的各种软件包),virtualenvs是一种很好的方法

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

这篇关于Numpy.dtype的大小错误,请尝试重新编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆