472,784 Members | 900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

ImportError: libclntsh.so.10.1: cannot open shared object file: Permission denied

Hi,

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
How can I fix the problem?

Any help would be appreciated,
Max

BTW:

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
#-------------------------------------------

Jul 20 '06 #1
3 24203
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
Jul 20 '06 #2
I have a similar question (importing cx_Oracle, but not related to
cron). I would like to use solution #2 below and it does not work. If
I set LD_LIBRARY_PATH before running python, it works. If I try to set
it via os.environ, it does not work.

I have tried this in an interactive Python shell. I can print the
value of os.environ["LD_LIBRARY_PATH"] and it is correct, but the
import fails. The cx_Oracle.so file is found, but when it tries to
load the necessary Oracle library (libclntsh.so.9.0), I get the
message:

ImportError: libclntsh.so.9.0: cannot open shared object file: No
such file or directory

Is there something else I have to do when changing os.environ before
trying the import?

Thanks,
David
P.S. Please post, as I don't read this e-mail account.

Damjan wrote:
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
Jul 27 '06 #3
I have a similar question (importing cx_Oracle, but not related to
cron). I would like to use solution #2 below and it does not work. If
I set LD_LIBRARY_PATH before running python, it works. If I try to set
it via os.environ, it does not work.

I have tried this in an interactive Python shell. I can print the
value of os.environ["LD_LIBRARY_PATH"] and it is correct, but the
import fails. The cx_Oracle.so file is found, but when it tries to
load the necessary Oracle library (libclntsh.so.9.0), I get the
message:

ImportError: libclntsh.so.9.0: cannot open shared object file: No
such file or directory

Is there something else I have to do when changing os.environ before
trying the import?
Well, all the oracle stuff is installed in /usr/lib/oracle on my computers
(or /usr/share/oracle ... depends when and how I installed it),
but I also always make the symbolic links in /usr/lib too.

I guess once Python is started (and the C level library loader) you can't
change LD_LIBRARY_PATH anymore.

What I ussually set in os.environ is ORACLE_HOME because the oracle library
still needs to find some additional files too.
BTW cx_Oracle seems to only need /usr/lib/libnnz10.so
and /usr/lib/libclntsh.so.10.1 but I also have these links in /usr/lib:
libclntsh.so -oracle/lib/libclntsh.so*
(this is a link to the .so.10.1 file)
libclntsh.so.10.1 -oracle/lib/libclntsh.so.10.1*
libnnz10.so -oracle/lib/libnnz10.so*
libocci.so -oracle/lib/libocci.so*
(this is a links to the .so.10.1 file
libocci.so.10.1 -oracle/lib/libocci.so.10.1*
libociei.so -oracle/lib/libociei.so*

This is with oracle instant client 10 libraries.
>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
--
damjan
Aug 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Douglass Turner | last post by:
Hi, Please release me from my own private hell. Platform: SuSE 8.1 I'm installing python 2.3 tarball as follows: ../configure --enable-shared make
1
by: Chris | last post by:
Thanks to Ingo for refering me to this group. I'm a newbie with perl scripts and I'm having problem running my copied script to my server. Can anybody who is patient enough to help me with my...
1
by: Joachim | last post by:
What could be the reasons for the following compilation error? c1xx : fatal error C1083: Cannot open compiler intermediate file: 'C:\Documents and Settings\Joachim Person\Local...
4
by: zombek | last post by:
I'm making a small program which takes a folder with images and generates optimized normal-sized images and thumbnails using Python Imaging Lbrary (PIL). The problem is here: ........
4
by: British | last post by:
This file is suppose to display "Welcome to the Zone!" and also write it to a text file instead i get an runtime error 0x800A0046 Permission Denied The Script: <html> <title>File Object</title>...
1
by: vasilip | last post by:
root@Server:/opt/ibm/db2/V9.1/bin# ./db2adutl ../db2adutl: error while loading shared libraries: libApiDS.so: cannot open shared object file: No such file or directory I just installed db2 9.1...
6
by: praveenkhade | last post by:
I am trying to open the Enterprise manager(sqlserver 2005) but following error is showing "mmc cannot open the selected file". yesterday it was working properly but since morning its not properly...
2
by: Rhuddlan | last post by:
Hi, I am using RedHat EL 4 and I developed an oracle 10g based application by using cx_Oracle (cx_Oracle-4.3.1-10g-py23-1.i386.rpm) and Python 2.3.4. Running the application through direct...
3
by: Rams chin | last post by:
Hi, Iam trying to build crda agent module on a cross platform(ARM). To build the same, one of the input module is m2crypto shared object file. I have sucesfully cross compiled and m2crypto.so file...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.