[mod_python] PythonPath problem

Graham Dumpleton grahamd at dscpl.com.au
Wed Mar 30 21:23:51 EST 2005


Shuying Wang wrote ..
> In the CGI script which has imported modules, I first had 
> "import x,  y" and when that resulted in "ImportError: No module named
> x", I tried
> from mod_python import apache
> xx =  apache.import_module("x") ...
> which also gave me the same error.

Try passing the actual directory in which the modules are located
into the import_module() function. Ie.,

  xx =  apache.import_module("x",path=[directory])

where "directory" is substituted with the actual path. By passing it
explicitly, you avoid the whole PythonPath problem as it will look
specifically in the specified directory.

Graham


More information about the Mod_python mailing list