[mod_python] problem to import pylab of matplotlib

Damien modpython at free.fr
Fri May 27 03:11:35 EDT 2005


Hello

I use fedora 3 with  python 2.3.4 ,  mod_python 3.1.3, apache2, Numeric 
23.3 , Numarray 1.3.2 , matplotlib 0.80

I want use mod_python with matplotlib but
in command line :

$ python 

>>> import pylab

>>> dir(pylab)

['ArrayType', 'Arrow', 'ArtistInspector', 'AutoLocator', 'Axes', 'Circle', 'Complex', 
'Complex32', 'Complex64', 'DAILY', 'DateFormatter', 'DateLocator', 'DayLocator', 'FR', 
'Figure', 'FigureCanvasBase', .......

>>> pylab.figure(1)

<matplotlib.figure.Figure instance at 0xb7f728cc>


it's Ok in command line.

But with mod_python :
my python.conf :

    <Directory "/var/www/html">

          AddHandler mod_python .py

          PythonHandler index

          PythonDebug On

    </Directory>


and my /var/www/html/index.py :

import pylab

from mod_python import apache

def handler(req):

        req.write("pylab function \n")

        for i in dir(pylab):

                req.write(i)

                req.write("\n")

        pylab.figure(1)

        return apache.OK



and the html output :

pylab function 
__builtins__
__doc__
__file__
__name__
cm
gzip
mlab

<pre>
Mod_python error: "PythonHandler index"

Traceback (most recent call last):

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

  File "/var/www/html/index.py", line 19, in handler
    pylab.figure(1)

AttributeError: 'module' object has no attribute 'figure'

</pre>

I have just 7 functins in pylab module.












More information about the Mod_python mailing list