savefig, too many open files

Hi

I have a script to plot and save a sequence of png images which I am using to prepare animations. This works fine, but I got the following error when preparing a particularly large number of files:

— record: 1015
— record: 1016
/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:990: GtkWarning: Failed to read filechooser settings from “/home/emason/.config/gtk-2.0/gtkfilechooser.ini”: Too many open files

Traceback (most recent call last):
File “fig_bry_paper_anim_vort.py”, line 245, in
File “/usr/lib/python2.5/site-packages/matplotlib/pyplot.py”, line 271, in savefig
File “/usr/lib/python2.5/site-packages/matplotlib/figure.py”, line 932, in savefig

File “/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py”, line 1085, in print_figure
File “/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py”, line 103, in print_png

File “/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py”, line 303, in print_png
RuntimeError: Could not open file /home/emason/Pictures/movies/cb_3km_emb_vort_1016.png

The script is simple, below I show a pared down version of the loop where the figures are created and saved (but not shown):

for cind in Cind:
P.figure(1)
P.pcolor(plon, plat, pF[cind])
P.colorbar()
P.savefig(fname[cind], dpi=150)
P.close(1)

Does anybody know why I get this error, and can anything be done about it?

Thanks, Evan