How to install scikits.ann

Jul 21, 2010 14:55

HOWTO: install scikits.ann

I wasted a day trying to install this python library. All howtos I found appeared to be almost useless. That's why I wrote one more useless piece of a crap

Question: how to install scikits.ann to python on Debian Squeeze (32-bit).

Before you start Make sure that you have easy_install and Python.h:

$ sudo apt-get install python-setuptools python2.6-dev

And think twice whether you need this deprecated wrapper.

Install Approximate Nearest Neighbors
First of all you need ANN library properly installed on your machine. I'm not sure that sudo apt-get install ann-tools libann0 libann-dev solves the problem. Okay, it's better to say, in my case is doesn't. (So I don't know the reason for them to be in the repo.)
* I downloaded ANN from here;
* unpack the archive and change the working directory to ANN's root directory;
* change Make-config a little bit:

70 # Linux using g++
71 linux-g++:
72         $(MAKE) targets \
73         "ANNLIB = libANN.a" \
74         "C++ = g++" \
75         "CFLAGS = -O3 -fPIC" \
76         "CPPFLAGS = -O3 -fPIC" \
77         "MAKELIB = ar ruv" \
78         "RANLIB = true"

* compile all the stuff with $ make linux-g++;
* copy the result to the proper place:
$ sudo cp -r bin/ include/ lib/ /usr/local/

Install the python wrapper for ANN
Now you can install scikits.ann:
* download source code from here (current version is 0.2.dev-r803 - 26/vii/2010);
* unpack the archive and change the working directory to its root directory;
* comment all lines (I had 5 ones) that you'll find via the following command:
$ grep NumpyTest ./* -r
* build and install the wrapper:
$ sudo apt-get install python-nose
$ python setup.py build_ext --inplace build test
$ sudo python setup.py install

Enjoy.

P.S. Perhaps this recipe will not work if you have 64-bit OS. (I tried on Ubuntu 10.04 64-bit, and did not succeed.) If you're tired of installing this package, simply type in python:

>>> import scipy.spatial as sp

and you get everything you need from ANN:

>>> dir(sp)
['KDTree', 'Rectangle', 'Tester', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '_distance_wrap', 'cKDTree', 'ckdtree', 'distance', 'distance_matrix', 'heappop', 'heappush', 'kdtree', 'minkowski_distance', 'minkowski_distance_p', 'np', 'scipy', 'test']

linux, python

Previous post Next post
Up