RuntimeError and fontCache

I updated the version of matplotlib distributed with our group’s software to 1.0.0 a week and a half ago (we also use wxPython 2.8.11.0 and Python 2.7). Since then, multiple users (all on Mac, so far, although we also distribute a Linux version) have been reporting this error:

RuntimeError : Could not open facefile /usr/local/bin/phenix-dev-610/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/VeraMono.ttf; Cannot_Open_Resource

The full traceback is appended below. Googling for this turned up multiple messages relating to older versions of matplotlib, but the only solution I could find was to remove the fontCache file in ~/.matplotlib (and it appears that in some cases removing the entire directory is necessary). The problem is that this appears to be necessary every time a user upgrades to a new version of our code and removes an older installation, and since we distribute nightly builds, it has become a daily ritual explaining how to fix the problem. I would really appreciate it if someone can suggest a more elegant solution than making my code nuke ~/.matplotlib. Alternately, if there is a way to completely prevent the creation or use of ~/.matplotlib, this would make my life much easier; so far this is the only Python module that I’ve seen that insists on writing to the home directory and crashes if it doesn’t get its way.

Or do I need to file a bug ticket?

thanks,

Nat

Traceback (most recent call last):

File “/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Runtime.py”, line 155, in OnUpdate
self.propagate_event(event, “OnUpdate”)
File “/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Runtime.py”, line 211, in propagate_event

fn(event)
File “/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Programs/Refine/Output.py”, line 517, in OnUpdate
self.stats_plot.update_stats(callback.data)
File “/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Programs/Refine/Output.py”, line 760, in update_stats

stats.bs_ave)
File “/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Programs/Refine/Output.py”, line 802, in set_plots
self.canvas.draw()
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.py”, line 59, in draw

FigureCanvasAgg.draw(self)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py”, line 394, in draw

self.figure.draw(self.renderer)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py”, line 55, in draw_wrapper

draw(artist, renderer, *args, **kwargs)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/figure.py”, line 798, in draw

func(*args)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py”, line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)

File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/axes.py”, line 1934, in draw
a.draw(renderer)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py”, line 55, in draw_wrapper

draw(artist, renderer, *args, **kwargs)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/axis.py”, line 1017, in draw

tick.draw(renderer)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py”, line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)

File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/axis.py”, line 234, in draw
self.label1.draw(renderer)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py”, line 55, in draw_wrapper

draw(artist, renderer, *args, **kwargs)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/text.py”, line 524, in draw

bbox, info = self._get_layout(renderer)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/text.py”, line 298, in _get_layout

ismath=False)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py”, line 180, in get_text_width_height_descent

font = self._get_agg_font(prop)
File “/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py”, line 221, in _get_agg_font

font = FT2Font(str(fname))
RuntimeError: Could not open facefile /usr/local/bin/phenix-dev-610/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/VeraMono.ttf; Cannot_Open_Resource

I think this issue has been totally fixed in the development branch
and I am pretty sure it is in the maintenance branch as well. Have
you tried the latest svn source in the v1_0_maint branch? It should
also have many, many other fixes.

Ben Root

···

On Friday, December 17, 2010, Nat Echols <nathaniel.echols@...287...> wrote:

I updated the version of matplotlib distributed with our group's software to 1.0.0 a week and a half ago (we also use wxPython 2.8.11.0 and Python 2.7). Since then, multiple users (all on Mac, so far, although we also distribute a Linux version) have been reporting this error:

RuntimeError : Could not open facefile /usr/local/bin/phenix-dev-610/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/VeraMono.ttf; Cannot_Open_Resource

The full traceback is appended below. Googling for this turned up multiple messages relating to older versions of matplotlib, but the only solution I could find was to remove the fontCache file in ~/.matplotlib (and it appears that in some cases removing the entire directory is necessary). The problem is that this appears to be necessary every time a user upgrades to a new version of our code and removes an older installation, and since we distribute nightly builds, it has become a daily ritual explaining how to fix the problem. I would really appreciate it if someone can suggest a more elegant solution than making my code nuke ~/.matplotlib. Alternately, if there is a way to completely prevent the creation or use of ~/.matplotlib, this would make my life much easier; so far this is the only Python module that I've seen that insists on writing to the home directory and crashes if it doesn't get its way.

Or do I need to file a bug ticket?

thanks,
Nat

Traceback (most recent call last):
File "/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Runtime.py", line 155, in OnUpdate
self.propagate_event(event, "OnUpdate")
File "/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Runtime.py", line 211, in propagate_event
fn(event)
File "/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Programs/Refine/Output.py", line 517, in OnUpdate
self.stats_plot.update_stats(callback.data)
File "/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Programs/Refine/Output.py", line 760, in update_stats
stats.bs_ave)
File "/usr/local/bin/phenix-dev-613/phenix/wxGUI2/Programs/Refine/Output.py", line 802, in set_plots
self.canvas.draw()
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.py", line 59, in draw
FigureCanvasAgg.draw(self)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 394, in draw
self.figure.draw(self.renderer)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/figure.py", line 798, in draw
func(*args)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/axes.py", line 1934, in draw
a.draw(renderer)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/axis.py", line 1017, in draw
tick.draw(renderer)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/axis.py", line 234, in draw
self.label1.draw(renderer)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/text.py", line 524, in draw
bbox, info = self._get_layout(renderer)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/text.py", line 298, in _get_layout
ismath=False)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 180, in get_text_width_height_descent
font = self._get_agg_font(prop)
File "/usr/local/bin/phenix-dev-613/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 221, in _get_agg_font
font = FT2Font(str(fname))
RuntimeError: Could not open facefile /usr/local/bin/phenix-dev-610/build/mac-intel-osx-x86_64/base/Python.framework/Versions/Current/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/VeraMono.ttf; Cannot_Open_Resource