【发布时间】:2016-09-21 14:30:09
【问题描述】:
我只是想成功运行一个 scikit-learn 示例源代码,但我得到一个一致的错误。代码可以在here 找到——它有大约 90 行代码,所以把它放在这里效率不高。但是,每当我运行它时,我都会收到从 Import sklearn 调用的错误消息,说明:
File "plot_outlier_detection.py", line 33, in <module>
from sklearn import svm
File "/Library/Python/2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Library/Python/2.7/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
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
主要错误是
ValueError: numpy.dtype has the wrong size, try recompiling
我已经查看了许多 Stackoverflow 帖子,说我需要更新我已经多次完成的 numpy、matplotlib、scipy(使用 pip 升级/卸载+安装/从源代码卸载+安装) ,但仍然出现相同的错误(我还重新安装了 sklearn)。我想我知道为什么会这样:
当我在终端中使用 python 并检查我得到的 numpy 版本时
import numpy
numpy.version.version
'1.9.2'
但是,当我尝试通过 pip 安装或升级时——我收到了消息
numpy in /Library/Python/2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.10-intel.egg
我在this Stackoverflow 中读到了关于这个的查询,他们说使用easy_install,因为python 没有从Mac 中的正确路径读取(IDK,有人可以确认吗?)所以我通过easy_install 完成了,并得到了这个留言
Searching for numpy
Best match: numpy 1.11.0
Processing numpy-1.11.0-py2.7-macosx-10.10-intel.egg
numpy 1.11.0 is already the active version in easy-install.pth
Installing f2py script to /usr/local/bin
Using /Library/Python/2.7/site-packages/numpy-1.11.0-py2.7-macosx-10.10-intel.egg
Processing dependencies for numpy
Finished processing dependencies for numpy
这是完全相同的事情。我真的不知道发生了什么事。谁能帮帮我?
版本参考:
Python - 2.7.10
Numpy - 1.9.2
Matplotlib - 1.4.3
Scipy - 0.13.0b1
其余版本也不是最新的..但它们源自 numpy 的最新版本。
【问题讨论】:
标签: python numpy matplotlib version-control machine-learning