I installed scikit-learn on following these instructions
Even when I try now to run again: sudo pip install -U scikit-learn
I get this message proving again that installation is ok:
Requirement already up-to-date: scikit-learn in /home/begueradj/.local/lib/python2.7/site-packages But I fail to import it:
begueradj@begueradj-Sampo:~/Desktop/begueradj$ python Python 2.7.6 (default, Mar 22 2014, 22:59:38) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sklearn Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named sklearn How to resolve this ?
3 Answers
The Ubuntu 14.04 package is named python-sklearn (formerly python-scikits-learn) and can be installed in Ubuntu 14.04-19.04 using the following command:
sudo apt install python-sklearn The python-sklearn package is in the default repositories in Ubuntu 14.04 as well as in other currently supported Ubuntu releases.
In Ubuntu 16.04 and later the Python 3 version of python-sklearn can be installed from the default Ubuntu repositories with the following command:
sudo apt install python3-sklearn 3When installing on Ubuntu Linux you have to have to install dependencies first using apt-get, then use a pip install otherwise the normal pip install of scikit-learn won't work properly. See below:
Step 1: Make sure apt-get is updated
sudo apt-get update Step 2: Install dependencies
sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy libatlas-dev libatlas3gf-base Step 3: pip install Scikit Learn
pip install --user --install-option="--prefix=" -U scikit-learn Hope this helps!
I've tried a lot of things but finally, including uninstall with the automated tools. So, I've uninstalled manually scikit-learn.
sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/sklearn sudo rm -R /home/ubuntu/.local/lib/python3.6/site-packages/scikit_learn-0.20.0-py3.6.egg-info And re-install using pip
sudo pip3.6 install -U scikit-learn