0
votes

So I am running this example that I found on Oracle's site on my linux machine. I have seen questions like this before, but the suggestions were not relevant in my case. I used pip install to download cx_oracle and I'm not entirely sure why it is failing to connect.

import cx_Oracle

con = cx_Oracle.connect('pythonhol/[email protected]/orcl')
print (con.version)

con.close()

Here is the error that I get:

cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help

I've looked up this error, but it seems as if this is unrelated to Oracle based on my google searches. Any guidance is appreciated.

1
Did you follow the instructions at that link for installing the 64-bit Oracle client library? cx_oracle won't work without it. - kfinity
Yes that library has been installed - David Abraham
Ok. Is the location where you unzipped it in your LD_LIBRARY_PATH? echo $LD_LIBRARY_PATH See also the official troubleshooting doc: cx-oracle.readthedocs.io/en/latest/… - kfinity
So where is libclntsh.so on your machine? - Bob Jarvis - Reinstate Monica
$LD_LIBRARY_PATH is located here: /home/david/Documents/oracle: as is the pyhton file i am running - David Abraham

1 Answers

0
votes

Seems you don't install the oracle client library in your system.
Before connecting to the oracle database server you have to install client package for oracle database server, You can download instant client library from oracle client library.

After installation run snippet:

       import cx_Oracle

       con = cx_Oracle.connect('pythonhol/[email protected]/orcl')
       print ('version:', con.version)

       con.close()
       # output: version: 12.0.1