I tried to run sklearn example, when I try to run it via terminal everything works fine but when I copy and paste this code in eclipse and try to run it I get this error:
Traceback (most recent call last): File "/Users/ABC/Documents/Eclipse/workspace/project/src/sklearn/plot_ROC.py", line 9, in <module>
from sklearn import svm, datasets ImportError: cannot import name svm
I check that both eclipse and system using the same version of python (at least I think so)
In terminal when I typed "which python" the result is "//anaconda/bin/python"
And in eclipse I set the same for Python interpreter as you can see in below picture.

So can anyone guide me what is the problem?
you may compare Python path under Eclipse and terminal by
import sys
print ( sys.path )
the order of entries does matter. My guess is that the fact that your Python file is in a folder called sklearn ( i.e .../project/src/sklearn) is messing the import statement.
requested edit: as it turned out, the problem was that the Python script was in a folder called sklearn and Python would look into that folder to import svm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With