0

我正在尝试使用import sklearn

from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split

但是我要么得到错误ModuleNotFoundError: No module named 'sklearn'要么It seems that scikit-learn has not been built correctly.

我已经尝试过以正常方式安装 scikit-learn 以及使用过去的版本 sudo pip install -U scikit-image==0.17.2 ,因为这可以解决很多情况。

4

2 回答 2

0

可能是为错误版本的python安装了模块,如果您使用的是python3,请使用:

python3 -m pip install scikit-learn

或者,对于 python 2

python -m pip install scikit-learn

usingwhich python将显示它指向的 python 版本。

于 2021-05-26T07:39:58.840 回答
0

我在另一篇文章中找到了答案:

安装没有实际问题,只需要更改导入顺序。就我而言,我必须让 sklearn 成为第一个导入对象。在这里进一步阅读

于 2021-06-07T06:53:57.340 回答