【问题标题】:Setting up scikit-learn - numpy errors on import设置 scikit-learn - 导入时出现 numpy 错误
【发布时间】:2013-03-07 21:24:48
【问题描述】:

我正在尝试设置 scikit-learn,但是在安装了 numpy 和 scikit-learn(使用 pip)之后,我在尝试 imort sklearn 时得到了这样的结果:

import sklearn
RuntimeError: module compiled against API version 8 but this version of numpy is 7
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/sklearn/__init__.py", line 32, in <module>
  from .base import clone
File "/usr/local/lib/python2.7/site-packages/sklearn/base.py", line 10, in <module>
  from scipy import sparse
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/__init__.py", line 182, in <module>
from .csr import *
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/csr.py", line 15, in <module>
from .sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/sparsetools/__init__.py", line 5, in <module>
from .csr import *
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/sparsetools/csr.py", line 26, in <module>
_csr = swig_import_helper()
File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130304-py2.7-macosx-10.8-intel.egg/scipy/sparse/sparsetools/csr.py", line 22, in swig_import_helper
_mod = imp.load_module('_csr', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

尝试重新安装东西没有成功

【问题讨论】:

标签: python installation pip scikit-learn


【解决方案1】:

查看 github 上的 this issue,听起来它可能需要特定版本的 numpy - 他们使用的是 1.7.0b2。

【讨论】:

  • 据我所知,这个问题与 scikit-learn 完全无关。
  • @AndreasMueller 我认为根本原因实际上可能与 this issue 有关,其中错误的库版本被优先考虑,而安装特定版本恰好可以解决该问题。
猜你喜欢
  • 2015-12-13
  • 2015-08-26
  • 2013-11-01
  • 2013-04-21
  • 2018-05-03
  • 1970-01-01
  • 2018-12-29
相关资源
最近更新 更多