1

I tried to install sci-kit learn module in python on ubuntu. As explained in their tutorial, I did:

pip install --user --install-option="--prefix=" -U scikit-learn

But when, in python console, I try

import sklearn

I get:

ImportError: No module named sklearn

Moreover, if I do

pip list

sklearn does not appear in the list.

And if I try:

sudo pip install scikit-learn

I get:

Requirement already satisfied (use --upgrade to upgrade): scikit-learn in ./.local/lib/python2.7/site-packages
Mostafa
  • 1,501
  • 3
  • 21
  • 37

2 Answers2

2

It's probably caused by the folder ~/.local/lib not appearing in your sys.path. You can update the sys.path in a couple of ways. Either set the PYTHONPATH environment variable before running the console, or just append to the sys.path array.

You could uninstall the module and then reinstall as root:

pip uninstall scikit-learn ; sudo pip install scikit-learn

You can also just delete the ~/.local/lib folder and reinstall the package.

Matthew Franglen
  • 4,441
  • 22
  • 32
  • uninstall is a good suggestion, but I get: Cannot uninstall requirement scikit-learn, not installed Storing debug log for failure in /home/ubuntu/.pip/pip.log – Mostafa Jan 14 '15 at 17:12
  • Perhaps you should just delete the ~/.local/lib folder. That should be equivalent to uninstalling the package. You may want to consider virtualenvwrapper as a way to handle these dependencies in future: http://virtualenvwrapper.readthedocs.org/en/latest/ – Matthew Franglen Jan 14 '15 at 17:17
  • I'm dealing with this error when I want to remove `scikit-learn` package: `Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. ` – Benyamin Jafari Mar 30 '19 at 18:38
  • @BenyaminJafari https://stackoverflow.com/questions/53807511/pip-cannot-uninstall-package-it-is-a-distutils-installed-project – vineeshvs Jun 07 '19 at 07:04
2

I had the same problem, but when I used sudo pip uninstall scikit-learn or sudo pip install -U scikit-learn I'm dealing with the following error:

Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

My problem solved by the following line:

sudo pip install --ignore-installed scikit-learn==0.18
Community
  • 1
  • 1
Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150