gpt4 book ai didi

python - pycharm 和终端中的 sklearn "numpy.dtype has the wrong size, try recompiling"

转载 作者:行者123 更新时间:2023-11-28 18:30:03 24 4
gpt4 key购买 nike

在编译 Sci-kit 学习时,我在 pycharm 和终端中都得到了“numpy.dtype has the wrong size, try recompiling”。我已经升级了所有包(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 的大小错误,请尝试重新编译”意味着 sklearn 是针对比 sklearn 现在尝试导入的 numpy 版本更新的 numpy 编译的。要解决此问题,您需要确保 sklearn 是针对它现在导入的 numpy 版本或早期版本编译的。参见 ValueError: numpy.dtype has the wrong size, try recompiling以获得详细的解释。

根据您的路径,我猜您正在使用 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 的包。

关于python - pycharm 和终端中的 sklearn "numpy.dtype has the wrong size, try recompiling",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38197086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com