use matplotlib in a cgi script

Hello,
I am trying to use matplotlib in a cgi script and I always get an error

the following script is the simplest script that reproduces the error

···

========================================
#!/sw/bin/python2.4

from pylab import *

and the error is always:

  File "/Library/WebServer/CGI-Executables/ldapstats.py", line 11, in ?
    from matplotlib.ticker import *
  File "/sw/lib/python2.4/site-packages/matplotlib/__init__.py", line 862, in ?
    rcParams = rc_params()
  File "/sw/lib/python2.4/site-packages/matplotlib/__init__.py", line
810, in rc_params
    fname = matplotlib_fname()
  File "/sw/lib/python2.4/site-packages/matplotlib/__init__.py", line
786, in matplotlib_fname
    fname = os.path.join(get_configdir(), 'matplotlibrc')
  File "/sw/lib/python2.4/site-packages/matplotlib/__init__.py", line
261, in wrapper
    ret = func(*args, **kwargs)
  File "/sw/lib/python2.4/site-packages/matplotlib/__init__.py", line
352, in _get_configdir
    raise RuntimeError("'%s' is not a writable dir; you must set
environment variable HOME to be a writable dir "%h)
RuntimeError: '/Library/WebServer' is not a writable dir; you must set
environment variable HOME to be a writable dir

what am i doing wrong?
any insight is appreciated
thanks,
-frank