我正在运行一个循环以生成2张地图。我遍历循环并第一次保存图像没有问题,但是当它再次运行并尝试保存图像(使用其他名称)时,我收到运行时错误。下面是回溯。
RuntimeError Traceback (most recent call last)
/var/folders/_z/g92ksvxx3xv69h89f57d3lsw0000gn/T/tmpRdJ6Jr.py in <module>()
214 savefigname = basin + "_outlook_latest.png"
215
--> 216 plt.savefig(save_fig + savefigname, dpi = 300)
217
218 #import ftplib
/Users/Brandon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/pyplot.py in savefig(*args, **kwargs)
695 def savefig(*args, **kwargs):
696 fig = gcf()
--> 697 res = fig.savefig(*args, **kwargs)
698 fig.canvas.draw_idle() # need this if 'transparent=True' to reset colors
699 return res
/Users/Brandon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/figure.py in savefig(self, *args, **kwargs)
1570 self.set_frameon(frameon)
1571
-> 1572 self.canvas.print_figure(*args, **kwargs)
1573
1574 if frameon:
/Users/Brandon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py in print_figure(self, *args, **kwargs)
220
221 def print_figure(self, *args, **kwargs):
--> 222 FigureCanvasAgg.print_figure(self, *args, **kwargs)
223 self.draw()
224
/Users/Brandon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2242 orientation=orientation,
2243 bbox_inches_restore=_bbox_inches_restore,
-> 2244 **kwargs)
2245 finally:
2246 if bbox_inches and restore_bbox:
/Users/Brandon/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
554
555 try:
--> 556 _png.write_png(renderer._renderer, filename_or_obj, self.figure.dpi)
557 finally:
558 if close:
RuntimeError: libpng signaled error
我已经在线寻找this solution,但是我想避免必须卸载然后重新安装(如果可能)。还有另一种方法可以解决此错误?考虑到第一个地图保存正确,我也不明白为什么我会首先收到此错误。