我得到"numpy "。dtype的大小不正确,在编译Sci-kit学习时,尝试在pycharm和terminal中重新编译"。我已经升级了所有的软件包(numpy, scikit到最新的),没有任何工作。Python版本为2.7。请帮助。欣赏!
checking for nltk
Traceback (most recent call last):
File "startup.py", line 6, in <module>
import nltk
File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import *
File "/Library/Python/2.7/site-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "/Library/Python/2.7/site-packages/nltk/chunk/api.py", line 13, in <module>
from nltk.parse import ParserI
File "/Library/Python/2.7/site-packages/nltk/parse/__init__.py", line 79, in <module>
from nltk.parse.transitionparser import TransitionParser
File "/Library/Python/2.7/site-packages/nltk/parse/transitionparser.py", line 21, in <module>
from sklearn.datasets import load_svmlight_file
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. "Dtype有错误的大小,try recompiling"意味着sklearn是针对比sklearn现在试图导入的numpy版本更新的numpy版本进行编译的。要解决这个问题,您需要确保sklearn是根据它现在导入的numpy版本或更早的版本编译的。参见ValueError: numpy。Dtype的大小错误,请尝试重新编译以获得详细的解释。
我猜从你的路径,你正在使用OSX系统Python(一个OSX附带的,在/usr/bin/python
)。Apple已经修改了这个Python,使它可以使用自己的numpy版本,而不是使用pip等安装的任何版本-参见https://github.com/MacPython/wiki/wiki/Which-Python#system-python-and-extra-python-packages。我强烈建议您切换到Python.org或自制Python,以便更轻松地使用依赖于numpy的包。
使用不兼容的版本时会出现此问题。查看版本:
pip freeze
或者,对于特定模块
pip freeze | grep Module_Name
我通过更新所有的包来修复我的问题:
pip install -U scikit-learn numpy scipy pandas matplotlib
截至今日(30/11/2016)。这些版本是兼容的:
matplotlib==1.5.2
nltk==3.2.1
numpy==1.11.2
pandas==0.19.1
scikit-learn==0.18.1
scipy==0.18.1
textblob==0.11.1