I tried to install scikit-learn in OSGeo4W Shell.
I used the information provided by another question 1.
Both ways as AlecZ suggested worked.
After installation I get this message: "Successfully installed scikit-learn-0.24.2"
Although when I open QGIS and then try to import sklearn I get this error: "ModuleNotFoundError: No module named 'sklearn.utils'"
How can I fix that and import the library?
Best Answer
On Windows, you must activate the QGIS environment before using pip
For QGIS 3.20 and higher: Open OsGeo shell, then type:
o4w_env
python3 -m pip install scikit-learn -U --user
For QGIS 3.18 and lower: Open OsGeo shell, then type:
py3_env.bat
python3 -m pip install scikit-learn -U --user