[mod_python] problem to import pylab of matplotlib

Damien modpython at free.fr
Fri May 27 07:38:35 EDT 2005


Graham Dumpleton wrote:

>
> On 27/05/2005, at 5:11 PM, Damien wrote:
>
>> 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
>
>
> If you print out __file__ from inside the loaded module, does it actually
> equate to the module you are expecting to load?

in command line and mod_python ( the same file) :

/usr/lib/python2.3/site-packages/pylab.pyc 

the content of /usr/lib/python2.3/site-packages/pylab.py is :

from matplotlib.pylab import *


If y replace the "import pylab" by "from matplotlib.pylab import *" in 
my index.py
i have a new error  :

pylab function 

<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 15, in handler
    for i in dir(pylab):

NameError: global name 'pylab' is not defined

</pre>


>
> Is "pylab" a module file or a package directory?

i think is a package directory in :

/usr/lib/python2.3/site-packages/matplotlib/

but there are *.so file in this directory.

>
> Graham

Merci, Damien

>
>
>



More information about the Mod_python mailing list