Kong Kuyjeu
Kong Kuyjeu

Reputation: 31

I can't import sklearn even if I already installed sklearn

I have already installed sklearn, but when I ran a python file that import sklearn, I get this:

Traceback (most recent call last):
  File "first.py", line 3, in <module>
    from sklearn import datasets
ModuleNotFoundError: No module named 'sklearn'

This is the result when I installed sklearn:

Requirement already satisfied: scikit-learn in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (0.24.0)
Requirement already satisfied: numpy>=1.13.3 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (1.19.4)
Requirement already satisfied: scipy>=0.19.1 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (1.5.4)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (2.1.0)
Requirement already satisfied: joblib>=0.11 in c:\users\user\appdata\local\programs\python\python38\lib\site-packages (from scikit-learn) (1.0.0)

Upvotes: 3

Views: 3161

Answers (3)

Ehsan Paknejad
Ehsan Paknejad

Reputation: 698

"sklearn" have changed to "scikit-learn" and "sklearn" is no longer works.

So in terminal:

pip install -U scikit-learn

more info in their site:

https://scikit-learn.org

https://scikit-learn.org/stable/install.html

Upvotes: 5

Emiliano
Emiliano

Reputation: 21

Firstly, make sure you update pip to latest version:

python -m pip install --upgrade pip

Then try:

pip install -U scikit-learn" on widnows terminal (cmd)

or try it with conda(if you have it on your pc)

conda install scikit-learn

also make sure you have installed numpy and scipy

pip install numpy

pip install scipy

Upvotes: 1

Renaldo
Renaldo

Reputation: 31

If you use anaconda you can still use pip to install packages:

pip install -U scikit-learn scipy matplotlib

For Python 3.x use:

pip3 install -U scikit-learn scipy matplotlib

Upvotes: 3

Related Questions