您的位置:首页 > 产品设计 > UI/UE

安装Scikit-learn:ValueError: numpy.dtype has the wrong size, try recompiling解决

2016-08-24 17:22 826 查看
今天在尝试使用scikit-learn的
AdaBoost
模型时一直报错,

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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

以为是
numpy
包的问题:卸载重装之后还是照样有问题-_-

网上给的建议大都是直接卸载再全部重装,将
numpy
scipy
scikit-learn
全部卸载了,然后

pip install -U numpy scipy scikit-learn

装起来。结果一样有问题-_-

继续查资料时终于发现有用的方法了:
http://scikit-learn-general.narkive.com/kMA6mRCk/valueerror-numpy-dtype-has-the-wrong-size-try-recompiling

就是不用使用
pip install scikit-learn
安装,卸载之后直接使用git上
https://github.com/scikit-learn/scikit-learn
的自己安装

git clone https://github.com/scikit-learn/scikit-learn make
sudo python setup.py install

ps:这个时候直接安装可能会出

RuntimeError: Running cythonize failed!

Error提示,这时候安装一下
cpython
即可

pip install cython

最后全部安装完之后就可以正常使用了^_^

本文转载自:http://kubicode.me/2016/04/22/Python/Solve-numpy-dtype-In-ValueError-when-using-scikit-learn/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: