ValueError:numpy.dtype的大小错误,导入分解

时间:2014-08-09 01:29:16

标签: python numpy scikit-learn

我试图使用sclearn.decomposition,但我得到了以下错误:

Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin

>>> import sklearn, numpy,scipy
>>> sklearn.__version__
'0.15.1'
>>> numpy.__version__
'1.6.2'
>>> scipy.__version__
'0.11.0'
>>> 
>>> from sklearn import decomposition
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/sklearn/decomposition/__init__.py", line 7, in <module>
    from .nmf import NMF, ProjectedGradientNMF
  File "/Library/Python/2.7/site-packages/sklearn/decomposition/nmf.py", line 21, in <module>
    from ..utils import atleast2d_or_csr, check_random_state, check_arrays
  File "/Library/Python/2.7/site-packages/sklearn/utils/__init__.py", line 10, in <module>
    from .murmurhash import murmurhash3_32
  File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling

我尝试使用pip卸载并安装所有软件包。不知道还有什么可以尝试任何建议吗?

更新

结果我以某种方式安装了旧版本的numpy / scipy我手动删除它们但现在我得到以下运行时错误:

/Library/Python/2.7/site-packages/scipy/stats/_continuous_distns.py:24: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
  from . import vonmises_cython
/Library/Python/2.7/site-packages/scipy/stats/_continuous_distns.py:24: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility
  from . import vonmises_cython
/Library/Python/2.7/site-packages/scipy/stats/stats.py:188: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
  from ._rank import rankdata, tiecorrect
/Library/Python/2.7/site-packages/scipy/stats/stats.py:188: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility
  from ._rank import rankdata, tiecorrect
/Library/Python/2.7/site-packages/scipy/spatial/__init__.py:90: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
  from .ckdtree import *
/Library/Python/2.7/site-packages/scipy/spatial/__init__.py:90: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility
  from .ckdtree import *
/Library/Python/2.7/site-packages/scipy/spatial/__init__.py:91: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
  from .qhull import *
/Library/Python/2.7/site-packages/scipy/spatial/__init__.py:91: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility
  from .qhull import *
/Library/Python/2.7/site-packages/scipy/interpolate/interpolate.py:28: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
  from . import _ppoly
/Library/Python/2.7/site-packages/scipy/interpolate/interpolate.py:28: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility
  from . import _ppoly

1 个答案:

答案 0 :(得分:0)

二进制文件似乎存在问题。我和熊猫有同样的错误,我通过卸载numpy和pandas并再次安装它来修复它。

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

请注意,安装pandas还会安装它的依赖项,例如numpy。

你的numpy和scipy版本似乎也很旧。尝试更新它们。