After pip install sklearn is successfully installed, it prompts ModuleNotFoundError: No module named 'sklearn' error solution

1. Wrong installation process

Currently in the conda virtual environment, install the sklearn module through the pip command

pip install sklearn

insert image description here
Then enter the python window and enter the following code

import sklearn

Start reporting an error: ModuleNotFoundError: No module named 'sklearn'
insert image description here

Two, the solution

View the information about installing the sklearn module with the following command

python -m pip show sklearn

insert image description here
As can be seen from the output results, the package is installed out of date, so we need to reinstall

2.1. Uninstall the installed package

pip uninstall sklearn

insert image description here

2.2. Install new packages

python -m pip install scikit-learn

insert image description here
After the installation is complete, enter the python window and enter

import sklearn

No error is reported, as shown in the figure below, it means that the installation is successful and can be successfully imported
insert image description here

Guess you like

Origin blog.csdn.net/HPGANG/article/details/130501079