2
from sklearn import svm 

I am getting the following error while importing sklearn modules.

/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/iterative.py in <module>() 9 10 from scipy.sparse.linalg.interface import LinearOperator ---> 11 from scipy.lib.decorator import decorator 12 from .utils import make_system 13 ImportError: No module named decorator ImportError Traceback (most recent call last) <ipython-input-6-e938be4cf50b> in <module>() ----> 1 from sklearn import svm /usr/local/lib/python2.7/dist-packages/sklearn/__init__.py in <module>() 54 # process, as it may not be compiled yet 55 else: ---> 56 from . import __check_build 57 from .base import clone 58 __check_build # avoid flakes unused variable error ImportError: cannot import name __check_build 

How to resolve this ?

1 Answer 1

1

I had the same error time ago, it is caused because either the machine doesn't have the scipy package installed, or it has the wrong distribution (depending on the architecture or OS).

If you have pip in your computer try installing scipy with:

sudo pip install scipy 

If you have it already try upgrading or reinstalling the package.

Edit:

Following the solution suggested by @erip, you can create a virtual environmentand test the solution keeping your python global site-packages directory clean:

virtualenv test # This creates a folder with the virtual env source test/bin/activate pip install scipy pip install sklearn 

To deactivate and remove the virtual env:

deactivate rm -r test # Remove the folder 
Sign up to request clarification or add additional context in comments.

1 Comment

Personally I wouldn't recommend sudo pip install anything and would opt for a virtualenv.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.