Having some issues getting a png to flow out to a web page. I am trying to use savefig( sys.stdout ), but I am getting an error. Well at least I can show the error when I run the script from a command prompt.
I took most of the example from the matplotlib pdf file. I added a couple print statements in order to get more feedback from the web server. When run from the command prompt in Windows, My output looks like this: hello world<br> This is the second line.<br> Traceback (most recent call last): File "C:\www\app\webroot\cgi-bin\stdout.py", line 12, in <module> savefig( sys.stdout ) File "C:\Python25\lib\site-packages\matplotlib-0.91.2.0001-py2.5-win32.egg\matplo tlib\pyplot.py", line 269, in savefig return fig.savefig(*args, **kwargs) File "C:\Python25\lib\site-packages\matplotlib-0.91.2.0001-py2.5-win32.egg\matplo tlib\figure.py", line 782, in savefig self.canvas.print_figure(*args, **kwargs) File "C:\Python25\lib\site-packages\matplotlib-0.91.2.0001-py2.5-win32.egg\matplo tlib\backend_bases.py", line 1195, in print_figure **kwargs) File "C:\Python25\lib\site-packages\matplotlib-0.91.2.0001-py2.5-win32.egg\matplo tlib\backends\backend_agg.py", line 397, in print_png self.get_renderer()._renderer.write_png(str(filename), self.figure.dpi.get()) RuntimeError: Could not open file <open file '<stdout>', mode 'w' at 0x00A0F068> --- Here is some version info: Windows XP Pro Python 2.5.2 matplotlib-0.91.2.0001-py2.5-win32.egg numpy-1.0.4.0002-py2.5-win32.egg My entire script is listed below: #!c:/Python25/python.exe -u print print "hello world<br>" import sys import matplotlib # this is not supported across all backends , as of matplotlib -0.63 matplotlib.use('Agg') from pylab import * print "This is the second line.<br>" plot ([1 ,2 ,3]) savefig( sys.stdout ) --- When I put this script in the cgi directory and refer to it in my URL, the response only shows Hello World. The "This is the second line." never displays. Seems that as soon as I import matplotlib I am not able to print to stdout. Any suggestions would be appreciated. -Rodney ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users