OSX Font cache problem

Hi-

I've got two Intel OSX machines running matplotlib.

I recently upgraded one of them to the latest MPL svn. On one machine, I had some pytz-related problems which I resolved, and I was able to use it more or less fine. However, when the very first time I started it, there was a huge pause which I eventually realized had something to do with the font cache, but it seems OK since then (but perhaps there should be a warning message when the cache is being built?)

On the other machine, however, I got the traceback below, which I eventually traced to the call OSXInstalledFonts() in findSystemFonts(). Unfortunately, OSXInstalledFonts() is really
    OSXInstalledFonts(directory=None, fontext=None)
which then calls
    fontext = get_fontext_synonyms(fontext)
which fails with fontext=None.

I was actually able to fix this by copying the .matplottlib directory
from the working machine, but it's still clearly a bug!

Yours,

Andrew

Traceback (most recent call last):
   File "/Users/jaffe/home/local/bin/ipython", line 8, in <module>
     load_entry_point('ipython==0.8.1', 'console_scripts', 'ipython')()
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 356, in launch_new_instance
     ses = make_session(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 405, in make_session
     return IPython.Shell.start(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1111, in start
     return shell(user_ns = user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1008, in __init__
     shell_class=MatplotlibShell)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 74, in __init__
     debug=debug,shell_class=shell_class)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipmaker.py", line 95, in make_IPython
     embedded=embedded,**kw)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 562, in __init__
     user_ns,b2 = self._matplotlib_config(name,user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 503, in _matplotlib_config
     import matplotlib.pylab as pylab
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/pylab.py", line 208, in <module>
     from matplotlib import mpl # pulls in most modules
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/mpl.py", line 3, in <module>
     from matplotlib import axis
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/axis.py", line 20, in <module>
     from font_manager import FontProperties
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1129, in <module>
     _rebuild()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1120, in _rebuild
     fontManager = FontManager()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 884, in __init__
     self.ttffiles = findSystemFonts(paths) + findSystemFonts()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 254, in findSystemFonts
     for f in OSXInstalledFonts():
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 180, in OSXInstalledFonts
     fontext = get_fontext_synonyms(fontext)
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 100, in get_fontext_synonyms
     'afm': ('afm',)}[fontext]
KeyError: None
gog:~% mv .matplotlib tmp.matplotlib; scp

Andrew Jaffe wrote:

Hi-

I've got two Intel OSX machines running matplotlib.

I recently upgraded one of them to the latest MPL svn. On one machine, I had some pytz-related problems which I resolved, and I was able to use it more or less fine. However, when the very first time I started it, there was a huge pause which I eventually realized had something to do with the font cache, but it seems OK since then (but perhaps there should be a warning message when the cache is being built?)

On the other machine, however, I got the traceback below, which I eventually traced to the call OSXInstalledFonts() in findSystemFonts(). Unfortunately, OSXInstalledFonts() is really
    OSXInstalledFonts(directory=None, fontext=None)
which then calls
    fontext = get_fontext_synonyms(fontext)
which fails with fontext=None.

I was actually able to fix this by copying the .matplottlib directory
from the working machine, but it's still clearly a bug!

Actually, sorry, this *doesn't* fix the problem on machine number 2 (it just lets ipython -pylab start without crashing, but actually calling, e.g., plot(x,y) still fails for the same reason).

···

Yours,

Andrew

Traceback (most recent call last):
   File "/Users/jaffe/home/local/bin/ipython", line 8, in <module>
     load_entry_point('ipython==0.8.1', 'console_scripts', 'ipython')()
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 356, in launch_new_instance
     ses = make_session(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 405, in make_session
     return IPython.Shell.start(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1111, in start
     return shell(user_ns = user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1008, in __init__
     shell_class=MatplotlibShell)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 74, in __init__
     debug=debug,shell_class=shell_class)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipmaker.py", line 95, in make_IPython
     embedded=embedded,**kw)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 562, in __init__
     user_ns,b2 = self._matplotlib_config(name,user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 503, in _matplotlib_config
     import matplotlib.pylab as pylab
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/pylab.py", line 208, in <module>
     from matplotlib import mpl # pulls in most modules
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/mpl.py", line 3, in <module>
     from matplotlib import axis
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/axis.py", line 20, in <module>
     from font_manager import FontProperties
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1129, in <module>
     _rebuild()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1120, in _rebuild
     fontManager = FontManager()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 884, in __init__
     self.ttffiles = findSystemFonts(paths) + findSystemFonts()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 254, in findSystemFonts
     for f in OSXInstalledFonts():
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 180, in OSXInstalledFonts
     fontext = get_fontext_synonyms(fontext)
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 100, in get_fontext_synonyms
     'afm': ('afm',)}[fontext]
KeyError: None
gog:~% mv .matplotlib tmp.matplotlib; scp

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

There is a (probable) fix for this in SVN r4179. I can't get to a Mac to test right now -- can you please confirm that fixes your problem? You may need to remove ~/.matplotlibrc/fontManager.cache (just once) in case the earlier bug has messed up the cache.

Andrew Jaffe wrote:

Andrew Jaffe wrote:

Hi-

I've got two Intel OSX machines running matplotlib.

I recently upgraded one of them to the latest MPL svn. On one machine, I had some pytz-related problems which I resolved, and I was able to use it more or less fine. However, when the very first time I started it, there was a huge pause which I eventually realized had something to do with the font cache, but it seems OK since then (but perhaps there should be a warning message when the cache is being built?)

Perhaps you have a lot of fonts on your system. I see your point about the warning message, but sometimes when the user is presented with too much information, they just train themselves to ignore all of it...

···

On the other machine, however, I got the traceback below, which I eventually traced to the call OSXInstalledFonts() in findSystemFonts(). Unfortunately, OSXInstalledFonts() is really
    OSXInstalledFonts(directory=None, fontext=None)
which then calls
    fontext = get_fontext_synonyms(fontext)
which fails with fontext=None.

I was actually able to fix this by copying the .matplottlib directory
from the working machine, but it's still clearly a bug!

Actually, sorry, this *doesn't* fix the problem on machine number 2 (it just lets ipython -pylab start without crashing, but actually calling, e.g., plot(x,y) still fails for the same reason).

Yours,

Andrew

Traceback (most recent call last):
   File "/Users/jaffe/home/local/bin/ipython", line 8, in <module>
     load_entry_point('ipython==0.8.1', 'console_scripts', 'ipython')()
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 356, in launch_new_instance
     ses = make_session(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 405, in make_session
     return IPython.Shell.start(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1111, in start
     return shell(user_ns = user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1008, in __init__
     shell_class=MatplotlibShell)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 74, in __init__
     debug=debug,shell_class=shell_class)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipmaker.py", line 95, in make_IPython
     embedded=embedded,**kw)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 562, in __init__
     user_ns,b2 = self._matplotlib_config(name,user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 503, in _matplotlib_config
     import matplotlib.pylab as pylab
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/pylab.py", line 208, in <module>
     from matplotlib import mpl # pulls in most modules
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/mpl.py", line 3, in <module>
     from matplotlib import axis
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/axis.py", line 20, in <module>
     from font_manager import FontProperties
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1129, in <module>
     _rebuild()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1120, in _rebuild
     fontManager = FontManager()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 884, in __init__
     self.ttffiles = findSystemFonts(paths) + findSystemFonts()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 254, in findSystemFonts
     for f in OSXInstalledFonts():
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 180, in OSXInstalledFonts
     fontext = get_fontext_synonyms(fontext)
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 100, in get_fontext_synonyms
     'afm': ('afm',)}[fontext]
KeyError: None
gog:~% mv .matplotlib tmp.matplotlib; scp

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

OK, the fix in the latest SVN does seem to work.

Andrew

···

On 9 Nov 2007, at 13:24, Michael Droettboom wrote:

There is a (probable) fix for this in SVN r4179. I can't get to a Mac to test right now -- can you please confirm that fixes your problem? You may need to remove ~/.matplotlibrc/fontManager.cache (just once) in case the earlier bug has messed up the cache.

Andrew Jaffe wrote:

Andrew Jaffe wrote:

Hi-

I've got two Intel OSX machines running matplotlib.

I recently upgraded one of them to the latest MPL svn. On one machine, I had some pytz-related problems which I resolved, and I was able to use it more or less fine. However, when the very first time I started it, there was a huge pause which I eventually realized had something to do with the font cache, but it seems OK since then (but perhaps there should be a warning message when the cache is being built?)

Perhaps you have a lot of fonts on your system. I see your point about the warning message, but sometimes when the user is presented with too much information, they just train themselves to ignore all of it...

On the other machine, however, I got the traceback below, which I eventually traced to the call OSXInstalledFonts() in findSystemFonts(). Unfortunately, OSXInstalledFonts() is really
    OSXInstalledFonts(directory=None, fontext=None)
which then calls
    fontext = get_fontext_synonyms(fontext)
which fails with fontext=None.

I was actually able to fix this by copying the .matplottlib directory
from the working machine, but it's still clearly a bug!

Actually, sorry, this *doesn't* fix the problem on machine number 2 (it just lets ipython -pylab start without crashing, but actually calling, e.g., plot(x,y) still fails for the same reason).

Yours,

Andrew

Traceback (most recent call last):
   File "/Users/jaffe/home/local/bin/ipython", line 8, in <module>
     load_entry_point('ipython==0.8.1', 'console_scripts', 'ipython')()
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 356, in launch_new_instance
     ses = make_session(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipapi.py", line 405, in make_session
     return IPython.Shell.start(user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1111, in start
     return shell(user_ns = user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 1008, in __init__
     shell_class=MatplotlibShell)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 74, in __init__
     debug=debug,shell_class=shell_class)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/ipmaker.py", line 95, in make_IPython
     embedded=embedded,**kw)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 562, in __init__
     user_ns,b2 = self._matplotlib_config(name,user_ns)
   File "/Users/jaffe/Library/Python/2.5/site-packages/ipython-0.8.1-py2.5.egg/IPython/Shell.py", line 503, in _matplotlib_config
     import matplotlib.pylab as pylab
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/pylab.py", line 208, in <module>
     from matplotlib import mpl # pulls in most modules
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/mpl.py", line 3, in <module>
     from matplotlib import axis
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/axis.py", line 20, in <module>
     from font_manager import FontProperties
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1129, in <module>
     _rebuild()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 1120, in _rebuild
     fontManager = FontManager()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 884, in __init__
     self.ttffiles = findSystemFonts(paths) + findSystemFonts()
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 254, in findSystemFonts
     for f in OSXInstalledFonts():
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 180, in OSXInstalledFonts
     fontext = get_fontext_synonyms(fontext)
   File "/Users/jaffe/Library/Python/2.5/site-packages/matplotlib-0.90.1_r4176-py2.5-macosx-10.3-fat.egg/matplotlib/font_manager.py", line 100, in get_fontext_synonyms
     'afm': ('afm',)}[fontext]
KeyError: None
gog:~% mv .matplotlib tmp.matplotlib; scp

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

______________________________________________________________________
Andrew Jaffe a.jaffe@...567...
Astrophysics Group +44 207 594-7526
Blackett Laboratory, Room 1013 FAX 7541
Imperial College, Prince Consort Road
London SW7 2AZ ENGLAND http://astro.imperial.ac.uk/~jaffe