Install AnnWrapper (scikits.ann) on Windows XP

ANN (Approximate Nearest Neighbor) is a C++ library for both exact and approximate nearest neighbor searching in arbitrarily high dimensions. I've been trying to use SWIG to wrap this library so I can use it in Python. Today I found out that someone had already done it! The project is called scikits.ann. They even have an already-to-use egg file for OS X 10.5. Since my primary operating system is Leopard, I installed the egg file and tried it out. Everything worked great! I needed to use this library under Windows XP also, however, due to some things at work. Here's how I got everything working.

First of all, make sure you have Cygwin installed (with the MinGW32 tools). We'll be using Cygwin to compile ANN. Also make sure you have Python 2.5 for Windows XP installed and Numpy.
You'll also need configobj, and obviously setuptools to be able to install the configobj egg. After all those files have been successfully installed, continue as follows (all these commands are within a Cygwin shell).

1. Compile and install ANN
Download from http://www.cs.umd.edu/~mount/ANN/Files/1.1.1/ann_1.1.1.tar.gz
Download the Windows XP Makefile from http://scipy.org/scipy/scikits/attachment/wiki/WindowsBuildInstructionsF...
Untar ann:
$ tar xfvz ann_1.1.1.tar.gz
Copy the annwinstuff.zip file into the ann_1.1.1 directory and unzip:
$ unzip annwinstuff.zip
Edit the ANN.h header file:
$ vi include/ANN/ANN.h
Replace lines 75 and 77 with:
#define DLL_API
Build ANN with mingw:
$ mingw32-make -f Makefile.win
Copy ANN includes to Cygwin includes:
$ cp -r include/ANN /usr/local/include/.
Copy ANN library to Cygwin lib:
$ cp lib/ANN.lib /usr/local/lib/.

2. Compile and install AnnWrapper
Download from http://pypi.python.org/packages/source/s/scikits.ann/scikits.ann-0.2.dev...
Edit site.cfg:
$ vi site.cfg
Change ANN_ROOT to: ANN_ROOT = c:/cygwin/usr/local
Build and install AnnWrapper:
$ /cygdrive/c/Python25/python.exe setup.py build_ext --inplace build -c mingw32 install

Hopefully you'll now have a working install of scikits.ann to use with the Windows version of Python 2.5! See the ANN documentation and the AnnWrapper documentation for information on how to use this module.

2 comments on Install AnnWrapper (scikits.ann) on Windows XP

  1. Rami (not verified)
    Thu, 03/19/2009 - 01:03

    Hey;
    Great thanks, you did it so good that it has worked for me. i've spent many hours trying to get ann work on windows (under python ofcourse) without success until i stumbled by this site.

    P.S. after i did all what u said, it has complained that it cannot import _ANN.py, so i copied ANN.pyd from the installation directory of scikits to C:\Python25\Lib\site-packages and it worked.

    Very informative.
    Great thanks

    Rami

  2. jared
    Sat, 10/10/2009 - 00:34

    I'm glad I could be of some help. (Yes, I'm replying 7 months after you posted this. I've been so busy with a new job and selling our house that I hadn't realized that there were some legitimate comments buried among the mass of spam in the moderation queue.)

Post new comment

Google Friend Connect (leave a quick comment)
Loading
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 12 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.