> I am using RedHat Linux 4. and I developed an oracle 10g based > application by using cx_Oracle (cx_Oracle-4.1-10g-py23-1.i386.rpm) and > Python 2.3.4. > > When I run the application through direct console connection, It works > perfect. > > But, when I schedule a crontab job to run the application, It logs this > error: > > Traceback (most recent call last): > File "/home/nsm1/NSM1/NSM1.py", line 5, in ? > import cx_Oracle > ImportError: libclntsh.so.10.1: cannot open shared object file: > Permission denied ... > I have the following settings in my /etc/profile file: > > #------------------------------------------- > ORACLE_BASE=/home/oracle/oracle/product > ORACLE_HOME=$ORACLE_BASE/10.2.0/db_1 > LD_LIBRARY_PATH=$ORACLE_HOME/lib > PATH=$PATH:$ORACLE_HOME/bin > ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data > export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH > #-------------------------------------------
These environment variables are important for running any programs that use the oracle client libraries. The problem you have is that when you run the script from cron these environment variables are not set. Now, there are several ways how to handle this: 1. create a shell script that you call from cron, and it it set the environment variables and then call you python program 2. modify the environment in your python program (via os.environ) and then import cx_Oracle 3. modify your system so that no environment variables are neccesseary - actually this is not possible, but what I have is, symbolic links in /usr/lib to the libraries in $ORACLE_HOME/lib, thus I don't need the LD_LIBRARY_PATH variable, and the only other variable I need is the ORACLE_HOME, which is /usr/share/oracle on my system and it contains bin/ install/ lib/ network/ ocommon/ oracore/ rdbms/ sqlplus/ -- damjan -- http://mail.python.org/mailman/listinfo/python-list