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
43 Answers
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:
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
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).
pip uninstall joblib pip install .../joblib-0.14.1-py2.py3-none-any.whl 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
