0

I am trying to import a sklearn function (fetch_openml) on Jupyter notebooks with the line: from sklearn.datasets import fetch_openml however, when running it I get the module not found error in the title.

I have installed the sklearn library with the following command prompt line: pip install sklearn yet Jupyter still returns the same issue.

DR DOT
  • 1
  • 2

1 Answers1

0

Sklearn is published as scikit-learn at PyPi, so it can be installed in terminal like this:

pip install scikit-learn

Or,

%pip install scikit-learn

in Jupyter. For more info; docs. See comments for more information about the difference between ! and %.

doneforaiur
  • 1,308
  • 7
  • 14
  • 21
  • 1
    Please no longer recommend the use of the exclamation point inside cells in modern Jupyter. The magic command was added a few years ago to insure the installations done in the notebook get installed, see [here](https://stackoverflow.com/questions/28828917/error-importing-seaborn-module-in-python-importerror-cannot-import-name-utils/76347896#comment134631387_41925357). The variation needed here should be `%pip install scikit-learn` for current best practives. See second paragraph ... – Wayne Jul 20 '23 at 15:25
  • 1
    [here](https://discourse.jupyter.org/t/location-of-libraries-or-extensions-installed-in-jupyterlab/16303/2?u=fomightez) on issues the use of the exclamation point with install commands can cause when run inside a notebook. There's a related magic install command for `conda`, too for those choosing that as their primary package manager, and so `conda install` should also not be used with exclamation point in modern Jupyter. In fact, because automagics are on by default usually, in general users are likely to have less issues if they use no symbol at all, as opposed to ... – Wayne Jul 20 '23 at 15:29
  • 1
    the exclamation point. However, it is always best be explicit and specify the magic symbol so you and others know what is happening when coming across this step later. Note this use of the magic symbol with install commands isn't pertinent to Google Colab which continues to be based on a very outdated branch of Jupyter. This fact isn't helping the situation as a lot of users not only find outdated information for Jupyter, they find advice related to Google Colab and don't realize it isn't truly standard Jupyter and indeed very outdated relative modern Jupyter. – Wayne Jul 20 '23 at 15:34
  • 1
    @Wayne, thank you for the information! I've edited my post. – doneforaiur Jul 20 '23 at 20:47