[mod_python] environment variables lost along the way

Graham Dumpleton graham.dumpleton at gmail.com
Tue Nov 25 18:06:50 EST 2008


2008/11/26 Josh Forman <jforman at wcgltd.com>:
> hi.  i've been working with modpython 3.3 on ubuntu 8.10 with python 2.5.
> i have a problem where, using a python module works in the python cli
> without doing anything special, but not in a script being run through
> apache.
> the module is cx_Oracle, and the error logs complain about being unable to
> acquire Oracle environment handle, and thus far everything i've read about
> this error is related to environmental variables needing to be set to
> something in particular.  so i have them set at boot by defining them in
> /etc/profile.   that didn't work.

Apache startup wouldn't use that, so don't expect it would work.

You may have more luck putting it in 'envvars' file in same directory
as httpd binary. This is presuming you are using Apache compiled from
source code. If using package Apache that file will not exist as they
generally do things their own way.

> so i added them into the script being run by assigning them through
> os.environ before i import cx_Oracle.

That should work. Did you restart Apache after making change to script?

> that didn't work either.
> so i added them into the virtual host config file as pythonoption
> directives, again with no luck.

That will not work, and neither will using SetEnv directive.

Graham

> i'm sure the error has to do with mod_python since the code in the python
> script works if run through the cli, but i am not sure and i've been pulling
> my hair out about this all day.
>
> the relevant part of the apache config is shown below:
> <Location /cdrs>
>        Options Indexes FollowSymLinks MultiViews
>        SetHandler mod_python
>        PythonPath "['/var/www/freeswitch'] + sys.path"
>        PythonHandler freeswitch.cdrs
>        PythonOption ORACLE_HOME /usr/lib/oracle/10.2.0.4/client64
>        PythonOption PYTHON_EGG_CACHE /tmp/egg_basket
>        PythonOption LD_LIBRARY_PATH /usr/lib/oracle/10.2.0.4/client64/lib
> </Location>
>
> _______________________________________________
> 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