Building and installing Gamera

Last modified: May 11, 2016


Linux (and other *nix)


  • Python 2.3 and later are supported, though Python 2.4 or later is recommended.

    You will need to have the headers (but not the complete source) to build Gamera from source code. Most Linux distributions include these as a separate package (eg. python-dev or python-devel).

  • wxPython 2.4.x or later (wxPython 2.8.x or later recommended for full functionality).

  • gcc version 3.1 or later.

  • libtiff 3.5.x or later

  • libpng 1.2.x or later

If any of these prerequisites is installed in a non standard directory, you can use the environment variables CFLAGS and LDFLAGS to pass its locations to the build script, e.g.:


Standard Build and Install

Gamera is built using the Python-standard Distutils system. Open a terminal and type:

python build
sudo python install

By default, parallelization of the genetica algorithms is only compiled into Gamera under Linux and with gcc version > 4.2, because we could only get it running in this environment. If you are sure that you have unbroken OpenMP support on your system, you can compile Gamera with:

python build --openmp=yes

If Gamera is compiled with OpenMP on your system, but OpenMP does not work on your system for some reason, you can switch it off with:

python build --openmp=no

Installing without root priviledges

If you do not have root access to your machine, you can make a local installation of Gamera.

A quick-and-easy way to do this is to use the script available here, and then follow the standard installation instructions (without using sudo):

python build
python install

Alternatively, you can set up a local installation by hand.

Make a local python module directory somewhere that you have write priviledges (such as your home directory):

mkdir ~/python

From the Gamera build directory, install Gamera into that directory:

python install --home=~/python

Set up an environment variables so Python can find stuff there (you may want to add this to your ~/.bash_profile file):

export PYTHONPATH=~/python/lib/python

Add the local Python scripts directory to your path:

export PATH=~/python/bin:$PATH

Now you should be able to run the gamera_gui script from the command line.


Run the gamera_gui script, which should have installed to /usr/local/bin. This file can also be copied anywhere (such as the Desktop) and double-clicked to run Gamera.


Running the script from the root of the source tree will not work, since it will not be able to find the compiled version of Gamera.

Installing without wxPython

When you need Gamera as a backend for document processing routines on a server and do not need the GUI, it can save a lot of trouble to avoid the installation of wxPython. For this case, use the option --nowx for

python --nowx build
sudo python --nowx install

Mac OS-X

Earlier versions of Gamera ran on OS-X by using X11 as an emulation of a standard Unix environment. The current SVN version of Gamera now uses Cocoa, and feels much more like a standard Macintosh application. Please follow the instructions for either X11 or Cocoa install below.

Native (Cocoa) build


Gamera installs out of the box on Mac OS-X 10.4 (Tiger) and 10.5 (Leopard). The only prerequisite is to install XCode, which is shipped with the OS-X installation DVD, but is not installed by default.

It should be noted that OS-X 10.4 comes with the unstable branch 2.5 of wxPython. So far we have not yet encountered any problems with this version, but if you have any problems, please consider to install wxPython 2.6 instead. This is not possible from the binary installers from, because there is none for Python 2.3, and the other Python versions require a particular prerelease of Xcode to build extensions, that is no longer available. So if you decide to upgrade wxPython on OS-X 10.4, you must do it from the source release of wxPython 2.6.

Standard Build and Install

Gamera is built using the Python-standard Distutils system.

To build Gamera, open a terminal and type:

python build

and then to install (you'll need to have admin priviledges):

sudo pythonw install

On OS-X 10.6 and later, you must define the variable CFLAGS before building Gamera as follows:

export CFLAGS="-stdlib=libstdc++ -mmacosx-version-min=10.6"

On OS-X 10.4, you must do the installation with pythonw rather than with python, because gamera_gui is a GUI application. On OS-X 10.5 this distinction is no longer necessary, but using pythonw also works.

On OS-X 10.5, the script gamera_gui is installed to /usr/local/bin, which is also in the default search PATH for programs. Prior to OS-X 10.5, the script gamera_gui was installed to /System/Library/Frameworks/Python.framework/Versions/2.?/bin, which is not in the default search PATH. You can either add this directory to your search PATH, or install the scripts to /usr/bin with:

sudo pythonw install_scripts -d /usr/bin


In its default configuraton, the Python distutils on MacOS X build fat binaries. You can speedup the compilation time by a factor two by removing the unnecessary architecture from your distutils build settings.

The critical part are the architecture options "-arch ppc" and "-arch i386". When you do not want to redistribute the compiled binaries, you can simply remove one of the architectures. Depending on the OSX/Python version, this is done in /Library/Framework/Python.framework/Versions/2.?/lib/python2.?/config/Makefile, or in /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/


Start the Terminal application and run the gamera_gui script.


Running the script from the root of the source tree will not work, since it will not be able to find the compiled version of Gamera.

X11 build

Please note that this build is no longer maintained by the Gamera developers. So use it only when the Cocoa build is not possible for some reason (e.g. on a legacy OS-X 10.3 system).


  • Mac OS-X 10.3 (Panther) or presumably later

  • Python 2.3 (including the version included).

  • wxPython-GTK 2.4.x or later

    Since there is no official build of the Gtk+/X11 version for Mac OS-X, I have made one available in the Gamera SourceForge Files section.

  • XCode. The version of XCode that shipped on the Tiger installation DVD will not work if you plan to use a newer version of Python downloaded from XCode 2.4.1, may be downloaded from .

  • X11. This is available on the Tiger installation DVD. You should also use Software Update to update X11 to the latest version.

Standard Build and Install

Download and install the unoffical wxPython-Gtk-X11 distribution from the Gamera Files section on SourceForge.

Alternatively, you can install fink and then build the package wxPython-Py23, which is currently in the unstable branch, (and its dependencies) from source. You will then need to use the fink version of Python (not the one that Apple provides) to carry out the instructions below.

Gamera is built using the Python-standard Distutils system.

To build Gamera, open a X11 terminal and type:

python build

and then to install (you'll need to have admin priviledges):

sudo python install

The scripts can be installed by:

sudo python install_scripts -d /usr/bin


The -d /usr/bin/ installs the scripts in a reasonable place on the PATH. If you do not specify it, the scripts are by default installed to /System/Library/Frameworks/Python.framework/Versions/2.3/bin.


Start an X11 terminal and run the gamera_gui script.


Running the script from the root of the source tree will not work, since it will not be able to find the compiled version of Gamera.

Microsoft Windows

Using the binary installer

The binary installers only work with one specific Python version so you must first make sure that your Python installation matches this version. The required version is indicated by the filename of the binary installer, e.g. for the 64bit version of Python 2.7.

Note that the installer might show an error message in the last screen, which can be ignored. The installer should create a script file on the desktop of the installing user, which can be used to start the Gamera GUI with a double click.

Installing from source

Currently, Gamera can be built using the MingW32/GNU toolset or with the Microsoft SDK. The Python core distribution for Windows officially only supports the latter option, though it is possible to use MingW, albeit only the 32bit version of MingW (gcc). The state is currently not very satisfactory, because MingW is not officially supported by Python and the Microsoft SDK is not officially supported by Gamera (volunteers are welcome!).

There are thus three options to compile Gamera on Windows:

If you have success with other compilers and configurations, please consider contributing your experiences to this documentation.


  • Python 2.5.x or later (only the distribution from has been tested)
  • wxPython 2.6.x or later (wxPython 2.8.x or later recommended for full functionality)

Microsoft SDK

For building extensions for Python 2.6, 2.7, 3.0, 3.1 and 3.2 (both 32 and 64 bit), Microsoft Visual C++ 2008 (Microsoft Visual Studio 9.0) is the compiler that is suitable. You will need the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1.

Note that this lacks some files required by the C99 standard, so you must additionally download the header files stdint.h and inttypes.h from the msinttypes project and copy them to the include directory of the SDK installation.

Assuming that you have installed the 64bit version of Python, you can compile Gamera with the following commands from the Microsoft SDK shell prompt (the color command is not necessary, but setenv can change the colors of the terminal to an unreadable combination):

setenv /x64 /release
color 0e
cd \path\to\gamera-sources
\path\to\python.exe bdist_wininst

The installer will be built in the subdirectory dist and can be startet by double click in the explorer. Note that the installer might display an error message at the end, depending on the Python distutils version shipped with your Python installation. This message can simply be ignored.

Standalone Mingw32

Install the Mingw32 port of gcc from Make sure that you do not only install gcc-core, but also g++ and make. Add the bin subdirectory of your Mingw32 installation to the environment variable PATH.

Assuming you have installed Python to C:\Python275, you can then compile gamera at a DOS command prompt from the root directory of the gamera source code with:

C:\Python27\python build --compiler=mingw32 bdist_wininst

This will create a Windows installer, including uninstallation support, in the dist subdirectory. It can be started with a double click in the Explorer, or from the DOS command prompt with:

start dist\gamera-*.exe


Fixes for common problems:

  • The Python 2.6 binary from requires libmsvcr90.a, which is an errenous in some versions of Mingw32. To fix it, you can recreate the file from the DLL msvcr90.dll that comes with Python 2.6 with pexports and dlltool (the latter is part of Mingw32):

    pexports msvcr90.dll > msvcr90.def
    dlltool --input-def msvcr90.def --dllname msvcr90.dll --output-lib libmsvcr90.a -k

    With Python 2.7 and Mingw gcc 4.6, these changes are not necessary.

  • Recent versions of the Mingw gcc no longer support the -mno-cygwin option, which is however passed on by the Python distutils. If you run into this error, you can simply remove the option from the file:


Mingw32 inside Cygwin

Use the installer from to install Cygwin, including the g++-mingw32 compiler and the MingW32 libraries. If you plan to track development of Gamera, you will probably also want to install subversion.

The important thing to note here is that we are using Cygwin's Mingw32 compiler to build for the standard (non-Cygwin) Python from After a clean install of Cygwin, typing 'python' will start up Cygwin's version of Python, not the one from Therefore, you will want to add the standard Python to your Cygwin PATH using the command (assuming you installed Python in standard location):

export PATH=/cygdrive/c/Python25/:$PATH

Ensure you are using the correct Python by typing:

which python

The result should be /cygdrive/c/Python25/python.exe, not /usr/bin/python.

Beware that the file /usr/bin/gcc installed by Cygwin actually is not the compiler executable, but a symbolic link. Symbolic links are not supported by MS Windows, but are a Cygwin-only feature. This means that the Python Distutils system cannot execute /usr/bin/gcc and the build command will fail. To fix this, replace the symbolic link with the actual compiler executable:

cp /usr/bin/gcc-3 /usr/bin/gcc
cp /usr/bin/g++-3 /usr/bin/g++

From here on, you can proceed as for the standalone Mingw32 toolchain, i.e.:

python build --compiler=mingw32 bdist_wininst