title: matplotlib and libpng issues with ipython notebook
body: <p>I was trying to use ipython notebook . I installed all the dependency libraries. However, I cannot use either the "--pylab=inline" option when launching ipython  or "savefig" function in the Ipython console. When I tried to do either of them, an error message was returned "RuntimeError: Could not create write struct" resulting from execution of matplotlib. Also, a warning from the notebookApp prompt said "libpng warning: Application built with libpng-1.2.41 but running with 1.5.13".</p>
  
  <p>However, I installed the newest libpng(1.5.13), uninstalled matplotlib with pip uninstall and reinstalled matplotlib with pip install (and during the build process, I can see that libpng1.5.13 is used for the building of matplotlib).</p>
  
  <p>The configuration for my system is Mac OS X10.6, python2.7. Anybody has similar experience or some suggestiongs?</p>
  
  <p>Here are the traceback errors:</p>
  
  <pre><code>[&lt;matplotlib.lines.Line2D at 0x106066d50&gt;]
  ---------------------------------------------------------------------------
  RuntimeError                              Traceback (most recent call last)
  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/zmq/pylab/backend_inline.pyc in show(close)
      100     try:
      101         for figure_manager in Gcf.get_all_fig_managers():
  --&gt; 102             send_figure(figure_manager.canvas.figure)
      103     finally:
      104         show._to_draw = []
  
  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/zmq/pylab/backend_inline.pyc in send_figure(fig)
      209     """
      210     fmt = InlineBackend.instance().figure_format
  --&gt; 211     data = print_figure(fig, fmt)
      212     # print_figure will return None if there's nothing to draw:
      213     if data is None:
  
  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt)
      102     try:
      103         bytes_io = BytesIO()
  --&gt; 104         fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight')
      105         data = bytes_io.getvalue()
      106     finally:
  
  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
     2050                     orientation=orientation,
     2051                     dryrun=True,
  -&gt; 2052                     **kwargs)
     2053                 renderer = self.figure._cachedRenderer
     2054                 bbox_inches = self.figure.get_tightbbox(renderer)
  
  /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
      501             _png.write_png(renderer._renderer.buffer_rgba(),
      502                            renderer.width, renderer.height,
  --&gt; 503                            filename_or_obj, self.figure.dpi)
      504         finally:
      505             if close:
  
  RuntimeError: Could not create write struct
  </code></pre>
  
  <p>Thanks a lot,</p>
  
  <p>Jie</p>