Reputation: 290
I'm trying to use import sklearn
and
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import train_test_split
However I either get the error ModuleNotFoundError: No module named 'sklearn'
or It seems that scikit-learn has not been built correctly.
I already tried installing scikit-learn the normal way as well as use a past-version sudo pip install -U scikit-image==0.17.2
since that solves it for a lot of cases.
Upvotes: 1
Views: 3781
Reputation: 290
I found the answer in another post:
There is no actual issue with installing, the order of imports just needs to be changed. In my case, I had to make sklearn the first import. Further reading here
Upvotes: 0
Reputation: 2709
It might be the case that the module is installed for the wrong version of python, if you are using python3, use :
python3 -m pip install scikit-learn
or, for python 2
python -m pip install scikit-learn
using which python
will show you which version of python, it is pointing to.
Upvotes: 1