3

I am new to python and installed it in windows OS and while following Google's machine learning tutorial on youtube, i encountered an error while importing the scikit package.

I installed the Anaconda package as shown in the tutorial but when importing sklearn i get an import error.

import sklearn

i also tried

from sklearn import tree

This is the error

Traceback (most recent call last):
  File "C:\Users\Raj Asha\Desktop\hello-world.py", line 2, in <module>
    from sklearn import tree
ModuleNotFoundError: No module named 'sklearn'

python version is 3.6.1

link to tutorial video https://www.youtube.com/watch?v=cKxRvEZd3Mw

4
  • Post the import statement used and also post how did you install the sklearn don't post video links Commented Jul 11, 2017 at 18:10
  • What is does the import error say? Paste it into your question. Commented Jul 11, 2017 at 18:10
  • Remove anaconda and Try pip install scikit-learn , pip install numpy , pip install scipy Commented Jul 11, 2017 at 18:12
  • Possible duplicate of Options for installing scikit-learn Commented Jul 11, 2017 at 18:19

3 Answers 3

6

Do you use Windows? From the error that you posted I say yes.

Open your terminal (cmd) and try these before you try to import the sklearn.

pip install -U scikit-learn

or

conda install scikit-learn

Also make sure your have numpy and scipy:

pip install numpy 
pip install scipy

EDIT

The conda error means that the conda is not in you PATH environment.

To solve this, Uninstall Anaconda and install it again, this time by selecting BOTH the options in the installation instruction as shown:

enter image description here

EDIT 2

If you do not have pip then, download from here the get-pip.py file and then use cmd to run python get-pip.py inside the folder in which get-pip.py is saved

Sign up to request clarification or add additional context in comments.

5 Comments

also pip install scipy
@sera 'conda' is not recognized as an internal or external command, operable program or batch file.
@Raj I edited my answer in order to solve the conda error. However, you can pip to install sklearn
@sera Even pip is not recognized as internal or external command
@Raj download from here the get-pip.py file and then use cmd to run "python get-pip.py" inside the folder in which get-pip.py is saved
1

I tried multiple solutions, but none of them worked. I installed the wheel files:

scipy-1.8.0-cp310-cp310-win_amd64.whl
numpy-1.22.3+mkl-cp310-cp310-win_amd64.whl
scikit_learn-1.0.2-cp310-cp310-win_amd64.whl

But I got error in: import sklearn

In my case, I was able to solve this by installing the whl file of the joblib (before, do: pip install wheel).

Download: https://github.com/wikimedia/research-ores-wheels/blob/master/joblib-0.14.1-py2.py3-none-any.whl

pip uninstall joblib
pip install .../joblib-0.14.1-py2.py3-none-any.whl

Comments

0

update your anaconda and python. I had the same problem. had to change my windows from 7 to 10 because python 3.9 doesn't support windows 7 or earlier anymore

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.