Cannot import scikits-learn even though it seems to be installed

Alan picture Alan · Nov 3, 2012 · Viewed 78.3k times · Source

Per the scikit-learn user guide, I installed scikit-learn using pip install -U scikit-learn.

So using pip search scikit-learn, I get this search result:

scikit-learn - A set of python modules for machine learning and data mining
INSTALLED: 0.12.1 (latest)

But when I go into Python and try to import sklearn, I get an ImportError: No module named sklearn. This really should have just worked.

I am using Enthought's free distribution of Python (2.7.3) on a Mac OS 10.6.8 with NumPy 1.6.1 and SciPy 0.10.1. Yes, I'm aware that EPD Free comes with scikit-learn but pip should have upgraded my version so that I can actually use scikit-learn.

Answer

Amey Jadiye picture Amey Jadiye · Jan 21, 2015

Got same problem, @Alan gave correct solution but hard way. Here are easy steps to resolve issue, as i am on mac osx, giving steps for same.

Ameys-Mac-mini:~ amey$ python --version
Python 2.7.2
Ameys-Mac-mini:~ amey$ cd /Library/Python/2.7/site-packages/
Ameys-Mac-mini:site-packages amey$ brew install gcc
Ameys-Mac-mini:site-packages amey$ sudo pip install -t . numpy scipy scikit-learn