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

Discussion in 'Python' started by gmax2006, Jul 20, 2006.

  1. gmax2006

    gmax2006 Guest

    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
    #-------------------------------------------
    gmax2006, Jul 20, 2006
    #1
    1. Advertising

  2. gmax2006

    Damjan Guest

    > 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
    Damjan, Jul 20, 2006
    #2
    1. Advertising

  3. gmax2006

    Guest

    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, 2006
    #3
  4. gmax2006

    Damjan Guest

    > 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
    Damjan, Aug 9, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TCMA
    Replies:
    0
    Views:
    1,456
  2. Douglass Turner
    Replies:
    2
    Views:
    2,012
    Manfred Bartz
    Sep 4, 2003
  3. Bill Scherer
    Replies:
    0
    Views:
    2,063
    Bill Scherer
    Jul 20, 2006
  4. Tim Golden
    Replies:
    0
    Views:
    947
    Tim Golden
    Aug 28, 2008
  5. Tony  Lay
    Replies:
    1
    Views:
    814
    Tony Lay
    Jul 13, 2009
Loading...

Share This Page