[mod_python] Problem with 'import' statement in 'execfile' script

Günter Dannoritzer dannoritzer at web.de
Fri Dec 12 19:09:36 EST 2003


Hello,

I have a problem with a python script I try to execute from a publisher 
handler with the command 'execfile'.

The script starts with the following lines:

import sys
sys.path.append('/ab/system')
from Tools.Utilities import Utilities

So I have the module Utilities under /ab/system/Tools and extend my path 
first so that the following from/import statement will find it.

When I call the web page (my publisher handler with the 'execfile' 
command) I get the error message:

    ImportError: No module named Tools.Utilities

When I execute the same script with 'python <scriptname>' or 
'execfile(<scriptname>)' out of python, it is executed without errors. 
Even when I do it with the user apache is running as.

If I leave the 'sys.path.append' command out and execute the script by 
itself I get the error message as well. So the 'sys.path.append' must 
basically work, just not when using it with the publisher handler.

My configuration is:

Apache-AdvancedExtranetServer/2.0.47 (Mandrake Linux/6.1.92mdk) 
mod_python/3.1.0a Python/2.3

Can anybody tell me why I get the error with the publisher handler and 
not when I execute the script by itself?

Thanks for your help.

Guenter






More information about the Mod_python mailing list