close

[Solved] ModuleNotFoundError: No module named ‘sklearn’

Hello Guys, How are you all? Hope You all Are Fine. Today I am just trying to import sklearn but I am facing following error ModuleNotFoundError: No module named ‘sklearn’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ModuleNotFoundError: No module named ‘sklearn’ Error Occurs ?

I am just trying to import sklearn but I am facing following error.

ModuleNotFoundError: No module named 'sklearn'

How To Solve ModuleNotFoundError: No module named ‘sklearn’ Error ?

  1. How To Solve ModuleNotFoundError: No module named ‘sklearn’ Error ?

    To Solve ModuleNotFoundError: No module named ‘sklearn’ Error Just use pip for installing packages. If You are using python 3 then use this command pip3 install -U scikit-learn scipy matplotlib. If You are using lower version of python then use this command. pip install -U scikit-learn scipy matplotlib. If you are using ubuntu then use this command to install sklearn sudo apt install python3-sklearn.

  2. ModuleNotFoundError: No module named ‘sklearn’

    To Solve ModuleNotFoundError: No module named ‘sklearn’ Error Just use pip for installing packages. If You are using python 3 then use this command pip3 install -U scikit-learn scipy matplotlib. If You are using lower version of python then use this command. pip install -U scikit-learn scipy matplotlib. If you are using ubuntu then use this command to install sklearn sudo apt install python3-sklearn.

Solution 1: install package with pip

Just use pip for installing packages. If You are using python 3 then use this command.

pip3 install -U scikit-learn scipy matplotlib

If You are using lower version of python then use this command.

pip install -U scikit-learn scipy matplotlib

Solution 2: For ubuntu users

If you are using ubuntu then use this command to install sklearn

sudo apt install python3-sklearn 

Solution 3: Reinstall sklearn

First of delete this directory to completely uninstall sklearn. ( For ubuntu users )

sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/sklearn
sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/scikit_learn-0.20.0-py3.6.egg-info

Now just reinstall sklearn with this command. The other name of sklearn in anaconda is scikit-learn.

sudo pip3 install -U scikit-learn

Solution 4: Using Conda

If you are using conda then run this command.

conda install scikit-learn

OR

conda install -n ML scikit-learn

Now, Your error might be solved.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

1 thought on “[Solved] ModuleNotFoundError: No module named ‘sklearn’”

Leave a Comment