matplotlib and mod_python

Hi all,
some students in our organisation sent me a problem with matplotlib and
mod_python, a simple script generates a plot of temp/pressure, all works fine
if they run it from the command-line, but if they use it from a apache web
server they receive this :

···

----------------------------------------------------
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136,
in
handler
    result = util.apply_fs_data(object, req.form, req=req)

  File "/usr/lib/python2.3/site-packages/mod_python/util.py", line 361, in
apply_fs_data
    return object(**args)

  File "/var/www/syrso_v2/tests/essai.py", line 11, in index

AttributeError: 'module' object has no attribute 'use'
---------------------------------------------------------

where the line 11 is :
matplotlib.use('Agg')
just after a import matplotlib!

Thanks for any help

--
Lionel Roubeyrie - lroubeyrie@...1068...
LIMAIR
http://www.limair.asso.fr

Hi all,
some students in our organisation sent me a problem with matplotlib and
mod_python, a simple script generates a plot of temp/pressure, all works fine
if they run it from the command-line, but if they use it from a apache web
server they receive this :
----------------------------------------------------
Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299, in
HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.3/site-packages/mod_python/publisher.py", line 136,
in
handler
    result = util.apply_fs_data(object, req.form, req=req)

  File "/usr/lib/python2.3/site-packages/mod_python/util.py", line 361, in
apply_fs_data
    return object(**args)

  File "/var/www/syrso_v2/tests/essai.py", line 11, in index

AttributeError: 'module' object has no attribute 'use'
---------------------------------------------------------

where the line 11 is :
matplotlib.use('Agg')
just after a import matplotlib!

Sounds like it is picking up on a file named matplotlib possibly. Try
adding "print matplotlib.__file__" after the "import matplotlib" line.
Make sure it is the same when running from the command line and
mod_python.

- Charlie

hi,
here is the output of repr(matplotlib):
<module 'matplotlib' from
'/usr/lib/python2.3/site-packages/matplotlib/__init__.pyc'>

and matplotlib.__version__
version : 0.82

···

Le Mardi 02 Mai 2006 14:06, Charlie Moad a écrit :

Sounds like it is picking up on a file named matplotlib possibly. Try
adding "print matplotlib.__file__" after the "import matplotlib" line.
Make sure it is the same when running from the command line and
mod_python.

- Charlie

--
Lionel Roubeyrie - lroubeyrie@...1068...
LIMAIR
http://www.limair.asso.fr

Is this the same under python command-line and mod_python? If you are
getting different results, it is most likely because the environment
is different in some way.

···

On 5/2/06, Lionel Roubeyrie <lroubeyrie@...1068...> wrote:

hi,
here is the output of repr(matplotlib):
<module 'matplotlib' from
'/usr/lib/python2.3/site-packages/matplotlib/__init__.pyc'>

and matplotlib.__version__
version : 0.82