0

I am trying to install scikit learn using

pip install -U scikit-learn

But it doesn't get installed. I tried to install numpy and scipy at first but I could not install those either :(

terminal error description

Zanna
  • 69,223
  • 56
  • 216
  • 327
AM.Firnas
  • 3
  • 2

1 Answers1

2

If you have root access on your machine and want to install the package system-wide you can just

sudo apt install python-sklearn 

If you do not want that or if you do not have root access then read on (the example is for python3; works for python2 just the same):

You need to install a virtualenv first (as non-root user) and then use pip within that virtualenv:

virtualenv -p /usr/bin/python3 /tmp/venv

Now you can either activate that venv and install:

$ . /tmp/venv/bin/activate
(venv) $ pip install -U scikit-learn

or directly call pip (with its full path):

/tmp/venv/bin/pip install -U scikit-learn

First, you may need to do:

sudo apt install python-dev

If you use the interpreter in that virtualenv (inside an activated shell or again with the complete path /tmp/venv/bin/python3 you should be able to use the scikit-learn package).

/tmp/venv/ is of course a stupid path to put the virtualenv; you'd usually have it somewhere in your /home.

Here are the docs for virtualenv (which included in the standard python distribution).

hiro protagonist
  • 1,489
  • 15
  • 32
  • 1
    Since the `python-scikits-learn` package is a transitional package, maybe use `python-sklearn` directly – muru Apr 18 '17 at 07:14
  • It works ! @hiro It's just an access permission error as you mentioned at first. I didn't focus much on error :( I installed python-scikits-learn, now how can I install python-sklearn ? – AM.Firnas Apr 18 '17 at 08:05
  • @AM.Firnas i was wrong at the beginning; you do not need `python-scikits-learn` (but it does not hurt either); just try to install `$ sudo apt install python-sklearn`. good luck! – hiro protagonist Apr 18 '17 at 08:16
  • Ok.So no need to uninstall anything.I can just install again by "sudo apt install python-sklearn" this, right ? – AM.Firnas Apr 18 '17 at 10:47
  • @AM.Firnas just tried on my ubuntu 16.04. works! – hiro protagonist Apr 18 '17 at 10:54