[Pythonmac-SIG] Problem bundling matplotlib with py2app: it looks for a font in /Library/Frameworks

Russell E. Owen rowen at uw.edu
Fri Oct 8 20:09:04 CEST 2010


I have a Mac python application I bundle with py2app. It has 
successfully included matplotlib for several years. However recently I 
added strip charts to it and now I find that the Mac bundle is broken: 
when I run on a system that does not have matplotlib installed it dies 
with a traceback that ends with:

Traceback (most recent call last):
  File ".../python2.6/RO/Wdg/Toplevel.py", line 138, in __init__
  File ".../python2.6/TUI/Guide/GuideMonitor/GuideMonitorWindow.py", 
line 56, in __init__
  File ".../python2.6/RO/Wdg/StripChartWdg.py", line 161, in __init__
  File ".../python2.6/RO/Wdg/StripChartWdg.py", line 314, in 
_updateTimeAxis
  File ".../python2.6/matplotlib/backends/backend_tkagg.py", line 251, 
in draw
  File ".../python2.6/matplotlib/backends/backend_agg.py", line 394, in 
draw
  File ".../python2.6/matplotlib/artist.py", line 55, in draw_wrapper
  File ".../python2.6/matplotlib/figure.py", line 798, in draw
  File ".../python2.6/matplotlib/artist.py", line 55, in draw_wrapper
  File ".../python2.6/matplotlib/axes.py", line 1934, in draw
  File ".../python2.6/matplotlib/artist.py", line 55, in draw_wrapper
  File ".../python2.6/matplotlib/axis.py", line 1017, in draw
  File ".../python2.6/matplotlib/artist.py", line 55, in draw_wrapper
  File ".../python2.6/matplotlib/axis.py", line 234, in draw
  File ".../python2.6/matplotlib/artist.py", line 55, in draw_wrapper
  File ".../python2.6/matplotlib/text.py", line 524, in draw
  File ".../python2.6/matplotlib/text.py", line 298, in _get_layout
  File ".../python2.6/matplotlib/backends/backend_agg.py", line 180, in 
get_text_width_height_descent
  File ".../python2.6/matplotlib/backends/backend_agg.py", line 221, in 
_get_agg_font
RuntimeError: Could not open facefile 
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pack
ages/matplotlib/mpl-data/fonts/ttf/Vera.ttf; Cannot_Open_Resource

where ... = 
/Users/rowen/TUI_1.8.2.1_Source/BuildForMac/dist/TUI.app/Contents/Resourc
es/lib

That font is available in the bundle itself:
ls -l 
TUI.app/Contents/Resources/lib/python2.6/matplotlib/mpl-data/fonts/ttf
total 4304
...
-rw-rw-r--  1 rowen  _rowen   65932 Jul  6 07:43 Vera.ttf
-rw-rw-r--  1 rowen  _rowen   63208 Jul  6 07:43 VeraBI.ttf
-rw-rw-r--  1 rowen  _rowen   58716 Jul  6 07:43 VeraBd.ttf
-rw-rw-r--  1 rowen  _rowen   63684 Jul  6 07:43 VeraIt.ttf
-rw-rw-r--  1 rowen  _rowen   55032 Jul  6 07:43 VeraMoBI.ttf
-rw-rw-r--  1 rowen  _rowen   49052 Jul  6 07:43 VeraMoBd.ttf
-rw-rw-r--  1 rowen  _rowen   54508 Jul  6 07:43 VeraMoIt.ttf
-rw-rw-r--  1 rowen  _rowen   49224 Jul  6 07:43 VeraMono.ttf
-rw-rw-r--  1 rowen  _rowen   60280 Jul  6 07:43 VeraSe.ttf
-rw-rw-r--  1 rowen  _rowen   58736 Jul  6 07:43 VeraSeBd.ttf
...

Does anyone have any ideas how to convince matplotlib to look for the 
font in the right place?

-- Russell

P.S. my configuration (though I've tried several others):
- Mac OS X 10.5 or 10.4
- python 2.6.6 (from python.org)
- matplotlib 1.0.0 (via the binary installer)
- py2app 0.5.2
- setuptools 0.6c11



More information about the Pythonmac-SIG mailing list