我试图在Linux Mint 12上安装scikit-learn,但失败了。我从http://pypi.python.org/pypi/scikit-learn/下载了软件包并安装了

sudo python2.7 setup.py install

然后,我将目录更改为home并启动python2.7 shell。在导入sklearn时,我得到了:
>>> import sklearn
/usr/lib/python2.7/dist-packages/scipy/spatial/__init__.py:7: RuntimeWarning:
numpy.dtype size changed, may indicate binary incompatibility
    from ckdtree import *
/usr/lib/python2.7/dist-packages/scipy/spatial/__init__.py:7: RuntimeWarning:
numpy.ndarray size changed, may indicate binary incompatibility
    from ckdtree import *
/usr/lib/python2.7/dist-packages/scipy/spatial/__init__.py:7: RuntimeWarning:
numpy.ufunc size changed, may indicate binary incompatibility
    from ckdtree import *
/usr/lib/python2.7/dist-packages/scipy/spatial/__init__.py:8: RuntimeWarning:
numpy.dtype size changed, may indicate binary incompatibility
    from qhull import *
/usr/lib/python2.7/dist-packages/scipy/spatial/__init__.py:8: RuntimeWarning:
numpy.ndarray size changed, may indicate binary incompatibility
    from qhull import *
/usr/lib/python2.7/dist-packages/scipy/spatial/__init__.py:8: RuntimeWarning:
numpy.ufunc size changed, may indicate binary incompatibility
    from qhull import *

我认为问题出在scipy的空间。这是因为当我做
>>> from scipy import spatial

我收到与Scikit-learn相同的错误。

请帮忙。
谢谢你。

编辑:新错误。
>>> import sklearn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.12_git-py2.7-linux-
x86_64.egg/sklearn/__init__.py", line 17, in <module>
    from .base import clone
  File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.12_git-py2.7-linux-
x86_64.egg/sklearn/base.py", line 11, in <module>
    from .metrics import r2_score
  File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.12_git-py2.7-linux-
x86_64.egg/sklearn/metrics/__init__.py", line 6, in <module>
    from .metrics import confusion_matrix, roc_curve, auc, precision_score, \
  File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.12_git-py2.7-linux-
x86_64.egg/sklearn/metrics/metrics.py", line 17, in <module>
    from ..utils import check_arrays
  File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.12_git-py2.7-linux-
x86_64.egg/sklearn/utils/__init__.py", line 9, in <module>
    from .murmurhash import murmurhash3_32
  File "numpy.pxd", line 174, in init sklearn.utils.murmurhash (sklearn/utils
/murmurhash.c:4776)
ValueError: numpy.ndarray has the wrong size, try recompiling

最佳答案

我不确定,但是根据this的说法,当针对特定版本(或特定平台)编译依赖于numpy的程序包,然后将该程序包安装在不同的环境中时,会发生错误。您是如何安装这两个软件包的? (numpy和scipy)

我建议先卸载这两个软件,然后再重新安装SciPy(using pipfrom source)。

关于python - 无法导入Scikit-Learn,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11464445/

10-12 21:45