1
votes

I want to use Reinteract to develop a machine-learning application. I'd like to use Sklearn's svm module, but when I run

import sklearn.svm

I get

File "C:\Python27\lib\site-packages\sklearn\svm__init__.py", line 13, in from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC File "C:\Python27\lib\site-packages\sklearn\svm\classes.py", line 1, in from .base import BaseLibLinear, BaseSVC, BaseLibSVM File "C:\Python27\lib\site-packages\sklearn\svm\base.py", line 2, in import scipy.sparse as sp ImportError: No module named sparse

Similarly, when I run

import sklearn.cluster

I get

File "C:\Python27\lib\site-packages\sklearn\cluster__init__.py", line 6, in from .spectral import spectral_clustering, SpectralClustering File "C:\Python27\lib\site-packages\sklearn\cluster\spectral.py", line 11, in from ..base import BaseEstimator, ClusterMixin File "C:\Python27\lib\site-packages\sklearn\base.py", line 10, in from scipy import sparse ImportError: cannot import name sparse

I am able to run

import sklearn

without error.

Reinteract on my Windows 7 machine is using

  • sys.version = 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
  • numpy.version.version = 1.6.1
  • scipy.version.version = 0.12.0
3
Switch to a UNIX machine. Your problems will go away.Slater Victoroff
@SlaterTyranus I know. All sorts of problems will go away, not just this one. I've sworn to myself many times that my next machine will be a linux box -- This time I mean it!rafaelcosman
I mean, partitioning your hard drive exists for a reason. Also Ringtail just came out.Slater Victoroff
Your SciPy installation seems to be broken. Can you import scipy.sparse?Fred Foo
import scipy.sparse gives me importError: numpy.core.multiarray failed to importrafaelcosman

3 Answers

1
votes

use PIP installer from https://pypi.python.org/pypi/pip

pip install -U scikit-learn
0
votes

Raphael, if you're on Windows i highly recommend a prepackaged install, like

PythonXY https://code.google.com/p/pythonxy/

Anaconda http://www.continuum.io/downloads (this works on Mac/Linux also)

or WinPython https://code.google.com/p/winpython/

the sklearn "stack" comes nicely packaged in all of them

-1
votes

(in Windows7 64bit) As Maxim says you can try Anaconda. (its faster!!!) It worked for me(updating Anaconda) with a similar problem(DLL import failed/ no module named svm)