FANN is a great artificial neural network library that has a low of language bindings. The latest version for now is 2.2. I’ve installed it at first. But than I discovered that python binging is part of 2.1 version not 2.2. So the plan is as follows.

  1. Download FANN 2.1 package.
  2. Install it as usual.
    ./configure
    make
    sudo make install
  3. You also nedd gcc, g++, swig, python and swig-python installed. There must be gcc and g++ already installed in the system.
  4. You need XCode installed. You can do it from Mac App Store.
  5. Then go to python/ folder of unzipped FANN directory. And you may try to run
    python setup.py install

    If no error occurs than you are done. Go to the last item.

  6. If you’re using XCode older than 4.4 than you may get error
    Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk

    That happens because of two things:

    1. There’s no such directory as /Developer. The solution is to create symlink:
       sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /Developer
    2. Second issue is about XCode not supporting SDK 10.6. So you may manually download it from Mac Dev Center or from http://www.jamesgeorge.org/uploads/MacOSX10.6.sdk.zip and place unzipped folder to
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer
  7. Try to run 5th item once more. If you get an error:
    unable to execute gcc-4.2: No such file or directory

    Just create symlink:

    sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

    All should work for now.

  8. The python files are now located in python/build/. Copy them to wherever you what to use them.
    cd build/lib.macosx-10.6-intel-3.2/pyfann/
    cp libfann.py <some location>
    cp _libfann.so <some location>

Here you find some old but not outdated examples of how to use FANN with python.

Share
Posted By admin

Leave a Reply

You must be logged in to post a comment.