4
votes

I've been trying to import sklearn but it says that the module is not found.

my python, numpy, scipy and scikit versions are as follows as show in the conda list:

numpy                     1.14.3           py36h9fa60d3_1

python                    3.6.5                h0c2934d_0

scipy                     1.1.0            py36h672f292_0

scikit-learn              0.19.1           py36h53aea1b_0

the error while trying to import sklearn is:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-f2461ba6e1e9> in <module>()
----> 1 from sklearn.family import model

ModuleNotFoundError: No module named 'sklearn.family'

I tried using

conda update scikit-learn

conda install scikit-learn

but I get the following results

All requested packages already installed.

how do I import sklearn then?

3
1) There is no module sklearn.family 2) you probably have multiple environments, and you are trying to work from Jupyter in one where the module is indeed not installed; try conda env list from the command line (or conda info --envs) to see your existing environments - desertnaut

3 Answers

2
votes

enter image description here

Although there is not skleran module, from sklearn import ... works well in PyCharm:

from sklearn.utils import resample
1
votes

Try doing

conda install -c anaconda pip
pip install sklearn
0
votes

AFAIK, there's no sklearn.family module. Have you tried importing other modules? Say,

from sklearn.model_selection import TimeSeriesSplit

Does that work for you?