How to build matplotlib with wx support

I build matplotlib 0.87.7 for Python 2.5 with support for TkAgg and WXAgg, the latter using the binary wxPython 2.7 installer from <http://pythonmac.org/packages>. Unfortunately, the matplotlib had a problem: WxAgg failed with:
MemoryError: _wxagg.convert_agg_to_wx_bitmap(): could not create the wx.Bitmap
Disaabling acceleration as follows seems to work around the problem, but I don't know how complete a fix it is:
import matplotlib.backends.backend_wxagg
matplotlib.backends.backend_wxagg._use_accelerator(False)

Christopher Barker was immensely helpful in explaining what was wrong. There are two issues:
1) The wxPython installer is finding the wrong wx-config. It finds the one for the outdated built-in wx instead of the one used by wxPython (which is deeply buried and very unlikely to be on your $PATH).
2) There are bugs in the particular wxPython 2.7 I was using that prevent building matplotlib. Note that 2.7.x is, by definition, a development branch; the next stable release series will be 2.8.x.

So the recipe that works is:
- Install wxPython 2.6.x (preferably the unicode version) from
   <http://www.wxpython.org/download-2.6.3.3.php#binaries>
or perhaps soon from:
    <http://pythonmac.org/packages/>

- Put its wx-config on your path. I did this as follows:
sudo ln -s /usr/local/lib/wxPython-unicode-2.6.3.3/lib/wx/config/mac-unicode-debug-2.6
I suggest removing the link when finished since it won't be updated if you ever update wxPython.
(Note: I found the correct file by looking for wx-config using File Buddy).

- Install one or more numeric of numpy, numarray and/or Numeric
Binary installers are available at <http://pythonmac.org/packages/>

- Build matplotlib as usual.

-- Russell

Russell E Owen wrote:

There are two issues:
1) The wxPython installer is finding the wrong wx-config. It finds the one for the outdated built-in wx instead of the one used by wxPython (which is deeply buried and very unlikely to be on your $PATH).
2) There are bugs in the particular wxPython 2.7 I was using that prevent building matplotlib. Note that 2.7.x is, by definition, a development branch; the next stable release series will be 2.8.x.

I'm not sure if it's a bug in wxPython 2.7 -- or a bug in the wxAgg code that happens to be triggered by 2.7...

- Put its wx-config on your path. I did this as follows:
sudo ln -s /usr/local/lib/wxPython-unicode-2.6.3.3/lib/wx/config/mac-unicode-debug-2.6

The other option is to set an environment variable, before running setup.py:
(bash syntax)

export WX_CONFIG=/usr/local/lib/wxPython-unicode-2.6.3.3/bin/wx-config

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...