我真的很痛苦這個問題很長時間。
最初,在繪製了matplotlib之後,我可以輕鬆保存圖像。
但是,安裝scipy之後,我無法保存我的圖像了。
(我使用pip安裝了matplot和scipy。)
我試圖查找一些信息,但仍然無法解決問題。
我的操作系統爲Mac OS X獅子(10.7)
python matplotlib和libpng不兼容問題
我認爲以下鏈接是一些相關問題
https://github.com/ipython/ipython/issues/2710
Matplotlib pylab savefig runtime error in python 3.2.3
matplotlib and libpng issues with ipython notebook
libpng15 static link issues
看來,如果我可以重新鏈接庫或設置DYLD_LIBRARY_PATH(實際上我不知道那是...)
或者我可能需要重新編譯一些東西?
順便說一下,我對基於Linux的系統非常陌生,所以如果有人能以相對簡單的方式解釋它,那將會非常好。 非常感謝。
下面是一些錯誤消息:
libpng warning: Application was compiled with png.h from libpng-1.5.4
libpng warning: Application is running with png.c from libpng-1.4.10
libpng warning: Incompatible libpng version in application and library
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/Library/Python/2.7/site-packages/matplotlib/backends/backend_macosx.pyc in save_figure(self, *args)
476 if filename is None: # Cancel
477 return
--> 478 self.canvas.print_figure(filename)
479
480 def prepare_configure_subplots(self):
/Library/Python/2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2094 orientation=orientation,
2095 bbox_inches_restore=_bbox_inches_restore,
-> 2096 **kwargs)
2097 finally:
2098 if bbox_inches and restore_bbox:
/Library/Python/2.7/site-packages/matplotlib/backend_bases.pyc in print_png(self, *args, **kwargs)
1856 from backends.backend_agg import FigureCanvasAgg # lazy import
1857 agg = self.switch_backends(FigureCanvasAgg)
-> 1858 return agg.print_png(*args, **kwargs)
1859
1860 def print_ps(self, *args, **kwargs):
/Library/Python/2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
502 _png.write_png(renderer._renderer.buffer_rgba(),
503 renderer.width, renderer.height,
--> 504 filename_or_obj, self.figure.dpi)
505 finally:
506 if close:
RuntimeError: Could not create write struct
你想解決這個PNG問題,或者你只是想在你的Mac上使用matplotlib? – carlosdc
是的,我必須解決PNG問題,因爲由於某些原因必須保存圖像。 – amigcamel
保存PNG?例如,解決方法是解決JPG問題。 – carlosdc