ImportError: no module named sklearn.datasets

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!

+7
source share
6 answers

export PYTHONPATH = $ PYTHONPATH: /usr/local/lib/python2.7/site-packages or export PYTHONPATH = $ PYTHONPATH: 'the path where your modules are installed'

to find out the path where your modules are installed, try starting the pp installation again and display the location

+5
source

When installing on Ubuntu Linux, you need to first install the dependencies using apt-get, and then use the pip installation, otherwise the normal scikit-learn installation will not work properly. See below:

Step 1. Verify that apt-get is updated .
Sudo apt-get update

Step 2. Installing the dependencies
sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base

Step 3: Select Scikit Learn
pip install --user --install-option = "- prefix =" -U scikit-learn

Hope this helps!

+2
source

Recently, a similar problem has occurred and spent too much time searching on Google, although the error was simple: my file was named sklearn.py Perhaps your import does not work.

+2
source

sklearn I was sure you installed. So, after creating a symlink sklearn to the Python interpreter, it went well.

 ln -s 'path of sklearn' 'path of python interpreter' 
0
source

The problem here may be how you import the package. Instead of import, for example,

from sklearn.datasets import load_iris

try it

 from sklearn import datasets iris_data = datasets.load_iris() 

It helped me hope this helps.

0
source

I have the same problem. I decided to just write:

 from sklearn import datasets data = datasets.load_iris() 
0
source

Source: https://habr.com/ru/post/1206878/


All Articles