pythonscikit-learnjupyter-notebookpippython-venv

Problem in installing and using scikit-learn in Python


I want to run the following code in jupyter-notebook

from sklearn.linear_model import SGDRegressor

before that, I have used the following lines in windows cmd:

python -m venv sklearn-env
sklearn-env\Scripts\activate
pip install -U scikit-learn

But still when I run the code, I get the error as:

No module named 'sklearn'

Any idea what is the problem?


Solution

  • I added the .venv kernel. Using the following codes

    pip install virtualenv
    

    and then

    pip install -U scikit-learn scipy matplotlib
    

    and the problem was solved.