Reputation: 101
os: mac os yosemite
python: 2.7.6 -- 64-bit
installed: numpy,skipy,matplotlib,nose
I get the following error.
>>> from sklearn.datasets import load_iris
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sklearn.datasets
$ pip install --user --install-option="--prefix=" -U scikit-learn
Requirement already up-to-date: scikit-learn in /Library/Python/2.7/site-packages
Cleaning up...
Someone help me please!
Upvotes: 9
Views: 39318
Reputation: 5038
Are you sure you're running the right Python? It may be that scikit-learn is only installed for Python3, and not Python 2, so you may need to run python3 my_code.py
instead of just python my_code.py
.
Upvotes: 0
Reputation: 45
I had the same problem. I solved just writing:
from sklearn import datasets
data = datasets.load_iris()
Upvotes: 1
Reputation: 51
Ran into a similar problem recently and spent too much time googling it while the error was simple: my file was named sklearn.py It might be why your import is not working.
Upvotes: 4
Reputation: 141
When installing on Ubuntu Linux you have to have to install dependencies first using apt-get, then use a pip install otherwise the normal pip install of scikit-learn won't work properly. See below:
Step 1: Make sure apt-get is updated
sudo apt-get update
Step 2: Install dependencies
sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base
Step 3: pip install Scikit Learn
pip install --user --install-option="--prefix=" -U scikit-learn
Hope this helps!
Upvotes: 2
Reputation: 3931
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages or export PYTHONPATH=$PYTHONPATH:'path where your installed modules are'
to find out the path where your modules are installed, try to run pip install again and it will output the location
Upvotes: 5
Reputation: 101
sklearn I was sure that you have installed. So, after you create a symbolic link the sklearn to Python interpreter, it went well.
ln -s 'path of sklearn' 'path of python interpreter'
Upvotes: 0