无法导入Scikit-Learn [英] Cannot import Scikit-Learn

查看:148
本文介绍了无法导入Scikit-Learn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried to install scikit-learn on my Linux Mint 12 but failed. I downloaded the package from http://pypi.python.org/pypi/scikit-learn/ and installed with

sudo python2.7 setup.py install

然后我将目录更改为home并启动python2.7 shell.在导入sklearn时,我得到了:

I then changed the directory to home and started python2.7 shell. On importing sklearn I got:

>>> 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的空间.这是因为当我这样做

I think the problem is with scipy's spatial. This is because when I do

>>> from scipy import spatial

我遇到的错误与Scikit学习中的错误相同.

I get the same error that I get for 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

推荐答案

我不确定,但是根据

I'm not really sure, but according to this that error happens when a package that depends on numpy is compiled targeting a specific version (or a specific platform), and that package is then installed in a different environment. How did you install those two packages? (numpy and scipy)

我建议同时使用pip 使用pip

I'd suggest uninstalling both and then reinstalling SciPy, either using pip or from source.

这篇关于无法导入Scikit-Learn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆