我试图使用 ipython notebook 。我安装了所有依赖库。但是,在启动 ipython 或 Ipython 控制台中的“savefig”函数时,我不能使用“--pylab=inline”选项。当我尝试执行其中任何一个时,由于执行 matplotlib,返回了一条错误消息“RuntimeError:无法创建写入结构”。此外,来自 notebookApp 提示的警告说“libpng 警告:使用 libpng-1.2.41 构建但使用 1.5.13 运行的应用程序”。
但是,我安装了最新的 libpng(1.5.13),使用 pip uninstall 卸载了 matplotlib,并使用 pip install 重新安装了 matplotlib(在构建过程中,我可以看到 libpng1.5.13 用于构建 matplotlib)。
我系统的配置是Mac OS X10.6,python2.7。有没有人有类似的经历或者建议?
以下是回溯错误:
[<matplotlib.lines.Line2D at 0x106066d50>]
---------------------------------------------------------------------------
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():
--> 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
--> 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()
--> 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,
-> 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,
--> 503 filename_or_obj, self.figure.dpi)
504 finally:
505 if close:
RuntimeError: Could not create write struct
非常感谢,
杰