2013-03-29 4 views
2

정말 오래이 문제로 고민 중입니다.
원래 matplotlib로 무언가를 플로팅 한 후에 이미지를 쉽게 저장할 수있었습니다.
그러나 scipy를 설치 한 후 더 이상 이미지를 저장할 수 없습니다.
(pip를 사용하여 matplot 및 scipy를 설치했습니다.)
몇 가지 정보를 찾으려고했으나 여전히 문제를 해결할 수 없습니다.
내 운영 체제가 맥 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

이 보인다 경우 I 라이브러리를 다시 링크하거나 DYLD_LIBRARY_PATH를 설정할 수 있습니다. (사실 그게 ...)

아니면 다시 컴파일해야합니까?
그건 그렇고, 나는 리눅스 기반 시스템에 매우 익숙하다. 그래서 누군가가 비교적 간단한 방법으로 그것을 설명 할 수 있다면 정말 좋을 것이다. 대단히 감사합니다.

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 
+0

이 PNG 문제를 해결 하시겠습니까, 아니면 Mac에서 matplotlib를 사용 하시겠습니까? – carlosdc

+0

몇 가지 이유로 이미지를 저장해야하므로 예, PNG 문제를 해결해야합니다. – amigcamel

+0

PNG 저장 하시겠습니까? 해결 방법은 JPG를 해결하는 것입니다. – carlosdc

답변

7

당신은 JPG를 저장할 경우 PNG 지원이 필요하지 않습니다

다음은 몇 가지 오류 메시지입니다.

import pylab as pl 
pl.plot([0.2,0.3,0.4], [0.1,0.2,0.3], label='series name') 
pl.xlabel('x label') 
pl.ylabel('y label') 
pl.ylim([0.0, 1.0]) 
pl.xlim([0.0, 1.0]) 
pl.title('Title') 
pl.legend(loc="lower left") 
pl.savefig('output.jpg') 
pl.show() 
+0

그것은 완벽합니다! ! 정말 고맙습니다! – amigcamel

+2

더 나은 옵션, IMO : pdf로 저장! 그것은 벡터 그래픽으로 텍스트 선택과 같은 재미있는 것들을 얻을 수 있습니다. –