Thursday, November 10, 2011

Installing the Marsyas Python bindings on Windows 7

In this post I assume you have followed the instructions from the previous post about installing Marsyas on Windows 7. To install the Python bindings you need to perform the following steps (I used Python 2.6 but I suspect that things should also work with Python 2.7). The python bindings to Marsyas do not require NumPy/SciPy and Matplotlib to work however having these package enables the creation of beautiful plots similar to MATLAB that help a lot with prototyping.

  1. Install Python 2.6 using the MSI Installer 
  2. Install NumPy using the superpack binary numpy-1.6.1-win32-superpack-python2.6.exe
  3. Install SciPy using the superback binary  scipy-0.10.0rc1-win32-superpack-python2.6.exe
  4. Install Matplotlib. I used matplotlib-1.1.0.win32-py2.6.exe from the Download link of the matplotlib website. 
Now you should be able to get nice MATLAB looking graphs in Python. To test start the Python command-line (or IDLE or whatever other method you have of editing Python code) and do:
>>> from pylab import *;
>>> x = randn(1000);
>>> hist(x);
>>> show() 
You should see a histogram plot of a rough bell-shape curve that will look something like this:

Congratulations you have a working Python/NumPy/SciPy matplotlib system. 

The next step is to install swig that is the program that generates the Python bindings. Download the archive that contains a pre-built executable for windows: Unzip the file. The next step will help ensure that swig and python can be found by CMake and consists of editing your PATH environment variable to point to the Python executable as well as the swig executable.

Right-click on Computer then select Properties and then select Advanced System Settings and Environment Variables.Under System Variables you will see the Path. Edit the path to add Python2.6 and swig.exe to it.

For example my Path looks like:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\ProgramFiles\Internet Exporer;C:\Program Files\CMake 2.8\bin;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\TortoiseSVN\bin;C:\Python26;C:\swigwin-2.0.4;

 Now we are ready to configure Maryas with the Python bindings using CMake. This can be done by ticking the WITH_SWIG option. If everything gets detected correctly the pink options will turn into grey and swig and python will be detected. This is how it looks on my machine:


Click generate and the Microsoft Visual Studio C++ Express solution file will be updated accordingly. 

The last part requires that you run Visual Studio as an administrator in order to be able to install the bindings and corresponding DLL to the default Python location for modules. To do that right-click on the icon for Visual Studio and select Run as Administrator. If needed confirm that you want to run as administrator and reopen the marsyas.sln file from the Marsyas build directory.

Right click on the ALL_BUILD target and select build to compile Marsyas. When all projects are finished then right click on the INSTALL target and select build.