[mod_python] problem to import pylab of matplotlib

Damien modpython at free.fr
Fri May 27 08:48:58 EDT 2005


Graham Dumpleton wrote:

>
> On 27/05/2005, at 9:38 PM, Damien wrote:
>
>> 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>
>
>
> You would need to use:
>
>   for in globals().keys():
>
> instead of:
>
>   for i in dir(pylab):
>
> as using "from matplotlib.pylab import *" imports them into your own
> globals.
>
> This means that instead of:
>
>   pylab.figure(1)
>
> you would also just use:
>
>   figure(1)
>
> Anyway, the original pylib.py should have worked as standard Python
> import is being used.
>
> One possibility for problems is that everything is contained in .so 
> files.
> There may be some sort of problem loading these within the context of the
> Apache process. I would though have expected to see a Python exception
> if there was.
>
> Only thing I can think of is to stop and start Apache and then look in
> the Apache error log file. There may be errors which are getting sent
> to stderr but which aren't getting flushed immediately (known issue).
> By shutting down Apache these error messages usually then get flushed
> and can be seen.
>
> Graham


Yes, with a fresh restart of apache server, i have a different error :

Mod_python error: "PythonHandler index"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 287, in HandlerDispatch
    log=debug)

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 457, in import_module
    module = imp.load_module(mname, f, p, d)

  File "/var/www/html/index.py", line 3, in ?
    import pylab

  File "/usr/lib/python2.3/site-packages/pylab.py", line 1, in ?
    from matplotlib.pylab import *

  File "/usr/lib/python2.3/site-packages/matplotlib/pylab.py", line 195, in ?
    from axes import Axes, PolarAxes

  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 12, in ?
    from axis import XAxis, YAxis

  File "/usr/lib/python2.3/site-packages/matplotlib/axis.py", line 20, in ?
    from font_manager import FontProperties

  File "/usr/lib/python2.3/site-packages/matplotlib/font_manager.py", line 991, in ?
    fontManager = FontManager()

  File "/usr/lib/python2.3/site-packages/matplotlib/font_manager.py", line 835, in __init__
    rebuild()

  File "/usr/lib/python2.3/site-packages/matplotlib/font_manager.py", line 829, in rebuild
    pickle.dump(self.ttfdict, file(ttfcache, 'w'))

IOError: [Errno 13] Permission denied: '/root/.ttffont.cache'

but when after 4 refresh of this page in my firefox, the error message 
change to the previous message.
why desactivate this phenomene ?

I have the same message in my apache log file exept this line :

[Fri May 27 14:46:10 2005] [notice] mod_python: (Re)importing module 'index'


I have a permession file error with the apache user.

Merci, Damien


More information about the Mod_python mailing list