EPS export broken in HEAD?

Howdy,

a simple

plot(rand(100))
savefig('foo.eps')

is giving me the traceback below. Is it something I'm doing wrong on my side?

Running on linux, ubuntu 10.10, python2.6.

Thanks for any tips...

f

···

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/fperez/research/dif-tx/src/python/<ipython-input-2-3f85c055f45e>
in <module>()
----> 1 savefig('foo.eps')

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/pyplot.pyc
in savefig(*args, **kwargs)
    426 def savefig(*args, **kwargs):
    427 fig = gcf()
--> 428 return fig.savefig(*args, **kwargs)
    429
    430 @docstring.copy_dedent(Figure.ginput)

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/figure.pyc
in savefig(self, *args, **kwargs)
   1160 kwargs.setdefault('edgecolor',
rcParams['savefig.edgecolor'])
   1161
-> 1162 self.canvas.print_figure(*args, **kwargs)
   1163
   1164 if transparent:

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_qt4agg.pyc
in print_figure(self, *args, **kwargs)
    151
    152 def print_figure(self, *args, **kwargs):
--> 153 FigureCanvasAgg.print_figure(self, *args, **kwargs)
    154 self.draw()

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backend_bases.pyc
in print_figure(self, filename, dpi, facecolor, edgecolor,
orientation, format, **kwargs)
   1977 orientation=orientation,
   1978 bbox_inches_restore=_bbox_inches_restore,
-> 1979 **kwargs)
   1980 finally:
   1981 if bbox_inches and restore_bbox:

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backend_bases.pyc
in print_eps(self, *args, **kwargs)
   1744 from backends.backend_ps import FigureCanvasPS # lazy import
   1745 ps = self.switch_backends(FigureCanvasPS)
-> 1746 return ps.print_eps(*args, **kwargs)
   1747
   1748 def print_pdf(self, *args, **kwargs):

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in print_eps(self, outfile, *args, **kwargs)
    933
    934 def print_eps(self, outfile, *args, **kwargs):
--> 935 return self._print_ps(outfile, 'eps', *args, **kwargs)
    936
    937

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in _print_ps(self, outfile, format, *args, **kwargs)
    966 self._print_figure(outfile, format, imagedpi,
facecolor, edgecolor,
    967 orientation, isLandscape, papertype,
--> 968 **kwargs)
    969
    970 def _print_figure(self, outfile, format, dpi=72,
facecolor='w', edgecolor='w',

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in _print_figure(self, outfile, format, dpi, facecolor, edgecolor,
orientation, isLandscape, papertype, **kwargs)
   1059 bbox_inches_restore=_bbox_inches_restore)
   1060
-> 1061 self.figure.draw(renderer)
   1062
   1063 if dryrun: # return immediately if dryrun (tightbbox=True)

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
     53 def draw_wrapper(artist, renderer, *args, **kwargs):
     54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
     56 after(artist, renderer)
     57

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/figure.pyc
in draw(self, renderer)
    872 dsu.sort(key=itemgetter(0))
    873 for zorder, func, args in dsu:
--> 874 func(*args)
    875
    876 renderer.close_group('figure')

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
     53 def draw_wrapper(artist, renderer, *args, **kwargs):
     54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
     56 after(artist, renderer)
     57

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/axes.pyc
in draw(self, renderer, inframe)
   1981
   1982 for zorder, a in dsu:
-> 1983 a.draw(renderer)
   1984
   1985 renderer.close_group('axes')

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
     53 def draw_wrapper(artist, renderer, *args, **kwargs):
     54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
     56 after(artist, renderer)
     57

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/axis.pyc
in draw(self, renderer, *args, **kwargs)
   1035
   1036 ticks_to_draw = self._update_ticks(renderer)
-> 1037 ticklabelBoxes, ticklabelBoxes2 =
self._get_tick_bboxes(ticks_to_draw, renderer)
   1038
   1039 for tick in ticks_to_draw:

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/axis.pyc
in _get_tick_bboxes(self, ticks, renderer)
    986 for tick in ticks:
    987 if tick.label1On and tick.label1.get_visible():
--> 988 extent = tick.label1.get_window_extent(renderer)
    989 ticklabelBoxes.append(extent)
    990 if tick.label2On and tick.label2.get_visible():

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/text.pyc
in get_window_extent(self, renderer, dpi)
    745 raise RuntimeError('Cannot get window extent w/o renderer')
    746
--> 747 bbox, info = self._get_layout(self._renderer)
    748 x, y = self.get_position()
    749 x, y = self.get_transform().transform_point((x, y))

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/text.pyc
in _get_layout(self, renderer)
    298 tmp, lp_h, lp_bl = get_text_width_height_descent('lp',
    299
self._fontproperties,
--> 300 ismath=False)
    301 offsety = lp_h * self._linespacing
    302

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in get_text_width_height_descent(self, s, prop, ismath)
    338 if rcParams['ps.useafm']:
    339 if ismath: s = s[1:-1]
--> 340 font = self._get_font_afm(prop)
    341 l,b,w,h,d = font.get_str_bbox_and_descent(s)
    342

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in _get_font_afm(self, prop)
    366 font = self.afmfontd.get(key)
    367 if font is None:
--> 368 fname = findfont(prop, fontext='afm',
directory=self._afm_font_dir)
    369 if fname is None:
    370 fname = findfont(

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/font_manager.pyc
in findfont(prop, **kw)
   1319 def findfont(prop, **kw):
   1320 global fontManager
-> 1321 font = fontManager.findfont(prop, **kw)
   1322 return font

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/font_manager.pyc
in findfont(self, prop, fontext, directory, fallback_to_default,
rebuild_if_missing)
   1211 default_prop = prop.copy()
   1212 default_prop.set_family(self.defaultFamily[fontext])
-> 1213 return self.findfont(default_prop, fontext,
directory, False)
   1214 else:
   1215 # This is a hard fail -- we can't find
anything reasonable,

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/font_manager.pyc
in findfont(self, prop, fontext, directory, fallback_to_default,
rebuild_if_missing)
   1226 result = best_font.fname
   1227
-> 1228 if not os.path.isfile(result):
   1229 if rebuild_if_missing:
   1230 verbose.report(

/usr/lib/python2.6/genericpath.pyc in isfile(path)
     27 """Test whether a path is a regular file"""
     28 try:
---> 29 st = os.stat(path)
     30 except os.error:
     31 return False

TypeError: coercing to Unicode: need string or buffer, NoneType found

It looks like something fishy in your font cache -- "None" has been entered in the table as a filename.

Can you move away your ~/.matplotlib/fontList.cache file (to force a regeneration) and see if that resolves the problem? If so, I'd like to see the original broken fontList.cache file to see if I can get to the bottom of what's wrong with it.

Have you set any font-related rcParams to anything non-standard that might be causing the lookup to fail?

Cheers,
Mike

···

On 06/21/2011 04:24 AM, Fernando Perez wrote:

Howdy,

a simple

plot(rand(100))
savefig('foo.eps')

is giving me the traceback below. Is it something I'm doing wrong on my side?

Running on linux, ubuntu 10.10, python2.6.

Thanks for any tips...

f

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/fperez/research/dif-tx/src/python/<ipython-input-2-3f85c055f45e>
in<module>()
----> 1 savefig('foo.eps')

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/pyplot.pyc
in savefig(*args, **kwargs)
     426 def savefig(*args, **kwargs):
     427 fig = gcf()
--> 428 return fig.savefig(*args, **kwargs)
     429
     430 @docstring.copy_dedent(Figure.ginput)

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/figure.pyc
in savefig(self, *args, **kwargs)
    1160 kwargs.setdefault('edgecolor',
rcParams['savefig.edgecolor'])
    1161
-> 1162 self.canvas.print_figure(*args, **kwargs)
    1163
    1164 if transparent:

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_qt4agg.pyc
in print_figure(self, *args, **kwargs)
     151
     152 def print_figure(self, *args, **kwargs):
--> 153 FigureCanvasAgg.print_figure(self, *args, **kwargs)
     154 self.draw()

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backend_bases.pyc
in print_figure(self, filename, dpi, facecolor, edgecolor,
orientation, format, **kwargs)
    1977 orientation=orientation,
    1978 bbox_inches_restore=_bbox_inches_restore,
-> 1979 **kwargs)
    1980 finally:
    1981 if bbox_inches and restore_bbox:

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backend_bases.pyc
in print_eps(self, *args, **kwargs)
    1744 from backends.backend_ps import FigureCanvasPS # lazy import
    1745 ps = self.switch_backends(FigureCanvasPS)
-> 1746 return ps.print_eps(*args, **kwargs)
    1747
    1748 def print_pdf(self, *args, **kwargs):

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in print_eps(self, outfile, *args, **kwargs)
     933
     934 def print_eps(self, outfile, *args, **kwargs):
--> 935 return self._print_ps(outfile, 'eps', *args, **kwargs)
     936
     937

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in _print_ps(self, outfile, format, *args, **kwargs)
     966 self._print_figure(outfile, format, imagedpi,
facecolor, edgecolor,
     967 orientation, isLandscape, papertype,
--> 968 **kwargs)
     969
     970 def _print_figure(self, outfile, format, dpi=72,
facecolor='w', edgecolor='w',

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in _print_figure(self, outfile, format, dpi, facecolor, edgecolor,
orientation, isLandscape, papertype, **kwargs)
    1059 bbox_inches_restore=_bbox_inches_restore)
    1060
-> 1061 self.figure.draw(renderer)
    1062
    1063 if dryrun: # return immediately if dryrun (tightbbox=True)

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
      53 def draw_wrapper(artist, renderer, *args, **kwargs):
      54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
      56 after(artist, renderer)
      57

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/figure.pyc
in draw(self, renderer)
     872 dsu.sort(key=itemgetter(0))
     873 for zorder, func, args in dsu:
--> 874 func(*args)
     875
     876 renderer.close_group('figure')

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
      53 def draw_wrapper(artist, renderer, *args, **kwargs):
      54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
      56 after(artist, renderer)
      57

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/axes.pyc
in draw(self, renderer, inframe)
    1981
    1982 for zorder, a in dsu:
-> 1983 a.draw(renderer)
    1984
    1985 renderer.close_group('axes')

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/artist.pyc
in draw_wrapper(artist, renderer, *args, **kwargs)
      53 def draw_wrapper(artist, renderer, *args, **kwargs):
      54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
      56 after(artist, renderer)
      57

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/axis.pyc
in draw(self, renderer, *args, **kwargs)
    1035
    1036 ticks_to_draw = self._update_ticks(renderer)
-> 1037 ticklabelBoxes, ticklabelBoxes2 =
self._get_tick_bboxes(ticks_to_draw, renderer)
    1038
    1039 for tick in ticks_to_draw:

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/axis.pyc
in _get_tick_bboxes(self, ticks, renderer)
     986 for tick in ticks:
     987 if tick.label1On and tick.label1.get_visible():
--> 988 extent = tick.label1.get_window_extent(renderer)
     989 ticklabelBoxes.append(extent)
     990 if tick.label2On and tick.label2.get_visible():

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/text.pyc
in get_window_extent(self, renderer, dpi)
     745 raise RuntimeError('Cannot get window extent w/o renderer')
     746
--> 747 bbox, info = self._get_layout(self._renderer)
     748 x, y = self.get_position()
     749 x, y = self.get_transform().transform_point((x, y))

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/text.pyc
in _get_layout(self, renderer)
     298 tmp, lp_h, lp_bl = get_text_width_height_descent('lp',
     299
self._fontproperties,
--> 300 ismath=False)
     301 offsety = lp_h * self._linespacing
     302

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in get_text_width_height_descent(self, s, prop, ismath)
     338 if rcParams['ps.useafm']:
     339 if ismath: s = s[1:-1]
--> 340 font = self._get_font_afm(prop)
     341 l,b,w,h,d = font.get_str_bbox_and_descent(s)
     342

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/backends/backend_ps.pyc
in _get_font_afm(self, prop)
     366 font = self.afmfontd.get(key)
     367 if font is None:
--> 368 fname = findfont(prop, fontext='afm',
directory=self._afm_font_dir)
     369 if fname is None:
     370 fname = findfont(

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/font_manager.pyc
in findfont(prop, **kw)
    1319 def findfont(prop, **kw):
    1320 global fontManager
-> 1321 font = fontManager.findfont(prop, **kw)
    1322 return font

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/font_manager.pyc
in findfont(self, prop, fontext, directory, fallback_to_default,
rebuild_if_missing)
    1211 default_prop = prop.copy()
    1212 default_prop.set_family(self.defaultFamily[fontext])
-> 1213 return self.findfont(default_prop, fontext,
directory, False)
    1214 else:
    1215 # This is a hard fail -- we can't find
anything reasonable,

/home/fperez/usr/opt/lib/python2.6/site-packages/matplotlib/font_manager.pyc
in findfont(self, prop, fontext, directory, fallback_to_default,
rebuild_if_missing)
    1226 result = best_font.fname
    1227
-> 1228 if not os.path.isfile(result):
    1229 if rebuild_if_missing:
    1230 verbose.report(

/usr/lib/python2.6/genericpath.pyc in isfile(path)
      27 """Test whether a path is a regular file"""
      28 try:
---> 29 st = os.stat(path)
      30 except os.error:
      31 return False

TypeError: coercing to Unicode: need string or buffer, NoneType found

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

Hi Mike,

It looks like something fishy in your font cache -- "None" has been
entered in the table as a filename.

Can you move away your ~/.matplotlib/fontList.cache file (to force a
regeneration) and see if that resolves the problem? If so, I'd like to
see the original broken fontList.cache file to see if I can get to the
bottom of what's wrong with it.

I think you're right, because now at my office I can't even reproduce
the problem.

The machine where I saw it is at home, so tonight I'll fish out the
font cache file and send it to you so you can investigate, along with
my matplotlibrc file, just in case.

Thanks, and sorry for the semi-false alarm!

Cheers,

f

···

On Tue, Jun 21, 2011 at 6:07 AM, Michael Droettboom <mdroe@...31...> wrote:

Hi Mike,

Can you move away your ~/.matplotlib/fontList.cache file (to force a
regeneration) and see if that resolves the problem? If so, I'd like to
see the original broken fontList.cache file to see if I can get to the
bottom of what's wrong with it.

here's the files from the machine that showed the problem:

http://fperez.org/tmp/fontList.cache
http://fperez.org/tmp/matplotlibrc

I hope they help you track down what can be happening, and perhaps a
layer of protection can be added to mpl so that it recovers gracefully
from this condition.

Cheers,

f

···

On Tue, Jun 21, 2011 at 6:07 AM, Michael Droettboom <mdroe@...31...> wrote: