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
1
  • 1
    any chance you are using a virtualenv? Commented Jan 14, 2015 at 17:07

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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
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: virtualenvwrapper.readthedocs.org/en/latest
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.
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.