From: John H. <jdh...@ac...> - 2005-02-02 12:35:55
|
>>>>> "dimitri" == dimitri pater <dim...@gm...> writes: dimitri> hello, I want to create a barchart on a website, somebody dimitri> advised me to use matplotlib and it does look very dimitri> promising. The problem that I now face is that I can't dimitri> seem to get things right, the following code results in dimitri> an import error: dimitri> from cgi import escape dimitri> try: import cgitb cgitb.enable() except: sys.stderr = dimitri> sys.stdout dimitri> # test import pylab import pylab dimitri> Does this mean that the webserver doesn't have pylab dimitri> installed or am I missing something? (bit of a newbie in dimitri> this area, so please bear with me...) To run matplotlib in a web app server, you will probably want to set "backend : Agg" in your .matplotlibrc file. matplotlib supports output to a variety of image devices and GUIs, and agg is a good choice to make nice PNGs for app servers. See http://matplotlib.sf.net/.matplotlibrc. On a standard linux install, this file would be placed in /usr/share/matplotlib/.matplotlibrc, and i can be copied to your HOME directory and edited. Often times HOME is not net in an app server environment. You either need to set it, or take a look at http://groups-beta.google.com/group/comp.lang.python/msg/09eac15acef8ee40, which describes some possible solutions. matplotlib needs a directory that is can write to to save some font cache information, and the link above describes the role of the environment variables HOME and MATPLOTLIBDATA in the choices matplotlib makes. As for your error, I suggest taking a minimal matplotlib script import pylab pylab.plot([1,2,3]) pylab.savefig('test.png') and running it with > python myscript.py --verbose-helpful and report any output and/or errors the script produces. Saying that you got an import error, without giving us the exact error message`, doesn't help us help you. Good luck! JDH |