Tuesday, August 28, 2012

Matplotlib bawls when it loses a font


Now this is a whiny, whiny error:
RuntimeError: Could not open facefile /sw/lib/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf; Cannot_Open_Resource

Apparently Matplotlib caches fonts, and then bawls when it can't find them.  Here's the stupid solution.

First, find out where your matplotlib config file lives:
matplotlib.get_configdir()  
In my case, it's ~/.matplotlib

Then, remove the font list cache:
 mv ~/.matplotlib/fontList.cache ~/.matplotlib/fontList.cache-old

No comments:

Post a Comment