1

i'm trying connect python cx_Oracle with the oracle client library in Centos 8, I have followed the steps showed in https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html, the rpm packages don't work so i used the zip package and config the LD_LIBRARY_PATH to the dir where i unzip the oracle files, in this case: /opt/oracle/lib.

When i run the script i get:

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "/opt/oracle/lib/libclntsh.so: cannot open shared object file: No such file or directory". See https://cx-oracle.readthedocs.io/en/latest/ user_guide/installation.html for help

but if i run: find /opt/oracle/lib/libclntsh.so it's works and the file is there, the env variable it's right according to the error message, but the script still not working, if anyone has any suggestions to fix this i would really appreciate it.

Update: when i set DPI_DEBUG_LEVEL=64 i get the following output:

ODPI [04293] 2021-04-10 15:51:06.109: ODPI-C 4.1.0
ODPI [04293] 2021-04-10 15:51:06.109: debugging messages initialized at level 64
ODPI [04293] 2021-04-10 15:51:06.110: Context Parameters:
ODPI [04293] 2021-04-10 15:51:06.110: Environment Variables:
ODPI [04293] 2021-04-10 15:51:06.110:     ORACLE_HOME => "/opt/oracle"
ODPI [04293] 2021-04-10 15:51:06.110:     LD_LIBRARY_PATH => "/opt/oracle/lib"
ODPI [04293] 2021-04-10 15:51:06.110: check module directory
ODPI [04293] 2021-04-10 15:51:06.110: module name is /usr/local/lib64/python3.6/site-packages/cx_Oracle.cpython-36m-aarch64-linux-gnu.so
ODPI [04293] 2021-04-10 15:51:06.110: load in dir /usr/local/lib64/python3.6/site-packages
ODPI [04293] 2021-04-10 15:51:06.110: load with name /usr/local/lib64/python3.6/site-packages/libclntsh.so
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: /usr/local/lib64/python3.6/site-packages/libclntsh.so: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: load with OS search heuristics
ODPI [04293] 2021-04-10 15:51:06.110: load with name libclntsh.so
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: libclntsh.so: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: load with name libclntsh.so.19.1
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: libclntsh.so.19.1: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: load with name libclntsh.so.18.1
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: libclntsh.so.18.1: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: load with name libclntsh.so.12.1
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: libclntsh.so.12.1: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: load with name libclntsh.so.11.1
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: libclntsh.so.11.1: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: load with name libclntsh.so.20.1
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: libclntsh.so.20.1: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: load with name libclntsh.so.21.1
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: libclntsh.so.21.1: cannot open shared object file: No such file or directory
ODPI [04293] 2021-04-10 15:51:06.110: check ORACLE_HOME
ODPI [04293] 2021-04-10 15:51:06.110: load in dir /opt/oracle/lib
ODPI [04293] 2021-04-10 15:51:06.110: load with name /opt/oracle/lib/libclntsh.so
ODPI [04293] 2021-04-10 15:51:06.110: load by OS failure: /opt/oracle/lib/libclntsh.so: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "cdr_parser.py", line 387, in <module>
    main()

And the script still not working.

Update 2: when i run: file /opt/oracle/lib/libclntsh.so i get:

/opt/oracle/lib/libclntsh.so: symbolic link to libclntsh.so.21.1

and running ldd /opt/oracle/lib/libclntsh.so the output is:

not a dynamic executable

Also, i verified libaio and liabio-devel install and it's correct, my Os's version is 64 bits and the instanclient is 64 bit too.

Oscar Gallo
  • 11
  • 1
  • 3

1 Answers1

2

Take a look at the documentation that was linked in the error message, in particular the troubleshooting section. In particular, set the environment variable DPI_DEBUG_LEVEL to the value 64 and run your script again. That will tell you all of the locations that are being searched and what the result of that attempt was. If this doesn't help, please update your question with the logged results. That may be enough to help further.

EDIT: as Chris mentioned, don't set the environment variable ORACLE_HOME when using the instant client. In addition, show the results of file /opt/oracle/lib/libclntsh.so and ldd /opt/oracle/lib/libclntsh.so and update your question with this information.

EDIT: use the new thin mode available in python-oracledb which doesn't require anything else installed.

Anthony Tuininga
  • 6,388
  • 2
  • 14
  • 23
  • Hi, i set DPI_DEBUG_LEVEL to 64, the output show that the env variables are correct but it still doesn't load the library, i edit the question with the new output. – Oscar Gallo Apr 10 '21 at 20:01
  • If you followed the instructions closely, you would _not_ have ORACLE_HOME set. We don't recommend setting this for Instant Client. Some things to do: check you have libaio installed. Check whether SQL*Plus runs. Check the Python process has access to `/opt/oracle/lib` and to the files within it. – Christopher Jones Apr 12 '21 at 02:40
  • I've added a few more things to update your question with. See my answer for more details. – Anthony Tuininga Apr 12 '21 at 15:26
  • I have attended you suggestions and updated my question with the outputs – Oscar Gallo Apr 12 '21 at 19:20
  • I see that. You need to find out *why* you are getting the error "not a dynamic executable". – Anthony Tuininga Apr 13 '21 at 03:09
  • 1
    well, I finally know what the error is, because my server is based on the aarch64 architecture, @AnthonyTuininga, please tell me, exists some alternative to connect with oracle database in this case? – Oscar Gallo Apr 16 '21 at 16:10
  • You would need to find a supported client. You could add an enhancement request on the cx_Oracle issues page -- just to make sure management is aware of the desire for alternative platforms. – Anthony Tuininga Apr 16 '21 at 17:42