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

Raaijmakers, Vincent (IndSys, GE Interlogix) Vincent.Raaijmakers at ge.com
Fri Dec 12 12:42:47 EST 2003


Is the package in your library/ site-packages ?
/usr/local/lib/python2.3/site-packages

and if so,

do you use perhaps soft links? ln -s /path_a/Tools /path_b/Tools
I had a lot of these issues using soft links.

Vincent

-----Original Message-----
From: mod_python-bounces at modpython.org
[mailto:mod_python-bounces at modpython.org]On Behalf Of Günter Dannoritzer
Sent: Friday, December 12, 2003 1:10 PM
To: mod_python at modpython.org
Subject: [mod_python] Problem with 'import' statement in 'execfile'
script


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




_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list