0
votes

I am trying to use scikit-learn svm to classify emails based on the topic. However, I am unable to import the svm module from sklearn. I already have sklearn installed. The error I get is as follows:

>>> from sklearn import svm

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    from sklearn import svm
  File "C:\Python27\lib\site-packages\sklearn\svm\__init__.py", line 13, in <module>
    from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC
  File "C:\Python27\lib\site-packages\sklearn\svm\classes.py", line 1, in <module>
    from .base import BaseLibLinear, BaseSVC, BaseLibSVM
  File "C:\Python27\lib\site-packages\sklearn\svm\base.py", line 8, in <module>
    from . import libsvm, liblinear
  File "numpy.pxd", line 155, in init sklearn.svm.libsvm (sklearn\svm\libsvm.c:9096)
ValueError: numpy.dtype has the wrong size, try recompiling

Any suggestions will be appreciated. Thanks!

1

1 Answers

1
votes

As the error message seems to suggest, I would try reinstalling scikit learn. If that doesn't work for you, you may also have to reinstall numpy/scipy.

You can use this pip command to upgrade scikit-learn to the latest version.

pip install -U scikit-learn