"ModuleNotFoundError: No module named sklearn" solution

When running an experiment recently, it is necessary to import sklearn, but the running code keeps prompting "ModuleNotFoundError: No module named sklearn".

The code to import sklearn in the experiment

from sklearn import metrics

According to the normal thinking, you should enter pip install sklearn at this time, but after execution, it shows that the version of sklearn in the running environment is 0.0post1, we should uninstall sklearn, because this is not the version we need.

pip uninstall sklearn

The full name of sklearn is scikit-learn, you should follow this package and use Tsinghua source.

But I still can't install it successfully by entering the installation code in the terminal of pycharm.

Finally, open Anaconda Prompt and enter the experimental environment.

activate xxx(xxx是运行环境名)

Then install scikit-learn

pip install scikit-learn -i https://pypi.tuna.tsinghua.edu.cn/simple/

After the installation is successful, enter pip list to check whether the installation is successful

pip list

You're done! sklearn installed successfully!

Guess you like

Origin blog.csdn.net/qq_43604183/article/details/128863955