Setting up scikit-learn - numpy errors on import

2019-02-26 01:24发布

I'm trying to set up scikit-learn, but after installing numpy and scikit-learn (using pip) that's what I get when trying to 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

Tried to reinstall things without success

1条回答
叛逆
2楼-- · 2019-02-26 01:48

Looking at this issue on github, it sounds like it might require a specific version of numpy - they used 1.7.0b2.

查看更多
登录 后发表回答