Python matplotlib plotting setup for cygwin

Matplotlib is a popular python library for generating plot graphics.   It works with cygwin win32 but some non-intuitive steps are required.

Install cygwin:

CYGWIN_NT-5.1 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin
I am using cygwin with setup 2.7.3

Install python through cygwin:

This document describes installing python and matplot with cygwin.  For most windows users and cygwin users, normally you would use the external python executable.  I tend to prefer all of my script oriented applications running through cygwin including python.


Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin

In the cygwin setup.exe installer, install:

The freetype libs, python-gtk, python-tk, libpng

Download matplotlib from sourceforge:

I am using the latest version matplotlib-1.1.0 as of 1/2012.

Issues with standard python install and cygwin:

The typical 'python setup.py install' will not work with cygwin.  You need to modify a configuration file and run some other additional commands.

In the root directory of the expanded matplotlib directory, edit the setup.cfg.template configuration file.

Around line 70 in the file is a commented line, uncomment the line such that you have:

tkagg = False

Run install and watch it fail

Try running 'python setup.py install'

It should fail with an error like the following:


2 [main] python 2796 C:\cygwin\bin\python.exe: *** fatal error - unable to remap C:\cygwin\bin\cyggfortran-3.dll to same address as parent: 0x18660000 != 0x69780000
Stack trace:


Run the rebase command OUTSIDE OF THE TYPICAL CYGWIN ENV

Exit cygwin and close all cygwin instances including the one you are working with.  You won't be using the typical  cygwin prompt for the next command.

In windows explorer, open the cmd.exe or windows command


You will need to run rebaseall.  First, shut down any long running processes like sshd, close all Cygwin prompts and so on.

Type the following commands:

cd \cygwin\bin
ash
PATH=. rebaseall -v

...
And you should get several lines of output.

Run install and watch it succeed

Try running 'python setup.py install' command again in the matplotlib directory

Running Example Program:


# python
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
import matplotlib.pyplot as pyplot
pyplot.pie([1,2,3])
pyplot.show()
pyplot.savefig('f.png')
pyplot.savefig('x.png')
pyplot.savefig('x.eps')

About Me (Berlin Brown resume):
http://berlin2research.com/dyna/berlinbrown_java_resume/

Comments

Popular posts from this blog

On Unit Testing, Java TDD for developers to write

Is Java the new COBOL? Yes. What does that mean, exactly? (Part 1)

JVM Notebook: Basic Clojure, Java and JVM Language performance