Notes on Ubuntu (Linux) computing

Brief notes on installation, setup and other tasks in the Ubuntu world

Install development version of scikit-learn

leave a comment »

In this post I will document my installation of (the bleeding edge, development version) of scikit-learn. You might not want to do this — there are stable releases with installation instructions available at the package website. In fact, there are Ubuntu/Debian-specific installation instructions. I would suggest using the Ubuntu package unless you know that you need that latest code. The reason for this is that dependencies will be taken care of by the package manager; otherwise you will have to figure out the dependencies yourself.

Now on to the specifics, assuming you want to install this version. First, change to a directory where you want the git repository to live, and clone the github repository:

git clone git://

Following the instructions, change directory to the repository and use the included Makefile

cd scikit-learn

This will build the package locally and run a bunch of tests (~2600 using nosetests) to make sure that everything works on you computer.

The commands in the Makefile do not install the package on the system. Instead, the scikit-learn website suggests including the path of the (built) package in your PYTHONPATH. I will do this in a slightly unconventional way that does not require admin privileges, allows the path to be included for a specific version of python, for a single user, and employs basic bash commands (this follows ideas from here — look for subsection on The bash way).

First, find out where your version of python has the user site-packages directory.

python -m site --user-site

If you have multiple versions of python installed and just want to affect python 2.6 you would use python2.6 -m site --user-site instead. Next, the directory provided by the above command may not exist. To make sure that it does, make the needed directory:

mkdir -p $(python -m site --user-site)

Again, substitute python with python2.6 in the above if you need to be more specific. Finally, we make a mypath.pth file in this directory that allows python to find scikit-learn:

echo "/home/username/gitLocal/scikit-learn" >> $(python -m site --user-site)/mypath.pth

This assumes that you cloned the scikit-learn repository in ~/gitLocal/. If you did not, change the above to reflect the location for you computer. Again, change the version of python employed, it needed.

Everything should be setup now. To test, cd to you home directory (make sure you are not in the scikit-learn directory) and start python:

cd ~

Now, import scikit-learn (hopefully without error):

import sklearn

At this point you can dig into the documentation and examples available at the website.


Written by Chris S

November 6, 2013 at 8:24 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: