[mod_python] environment variables lost along the way

Josh Forman jforman at wcgltd.com
Tue Nov 25 17:44:54 EST 2008


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.
so i added them into the script being run by assigning them through  
os.environ before i import cx_Oracle.  that didn't work either.
so i added them into the virtual host config file as pythonoption  
directives, again with no luck.
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>



More information about the Mod_python mailing list