Can we connect to oracle database using python in linux without "cx_Oracle" library. We have a restriction of installing "Oracle Instant client which is mandatory required for cx_oracle library" .

We are getting below error while trying to connect to oracle database using "cx_Oracle"

Error: cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle 
Client library: "libclntsh.so: cannot open shared object file: No such 
file or directory"

Please suggest if there is any way to connect to oracle without "cx_oracle" and without installing Instant client

  • Please edit your question to explain what you've tried. In particular, please explain why the instructions on the referenced page in the error message didn't help you. Thanks. – roaima Aug 20 '19 at 7:46
  • @roaima. I have added all the details. We have installed a library "cx_Oracle" in linux server to access the oracle database using python, but it was throwing this error while i am executing the python script. – Arya Aug 20 '19 at 7:49
  • If that's literally all you've done then you need to do what the referenced instructions tell you to do. – roaima Aug 20 '19 at 8:36
  • @roaima. I edited the question.. – Arya Aug 20 '19 at 9:09
  • 2
    Maybe this will help: stackoverflow.com/questions/53304473/… – Mark Plotnick Aug 20 '19 at 10:06

You've asked

if there is any way to connect to oracle without "cx_oracle" and without installing Instant client

The documentation referenced from the error message clearly states

ODPI-C requires Oracle Client libraries, which are found in Oracle Instant Client, or an Oracle Database installation, or in a full Oracle Client installation.

If you haven't got one of these three configuration options you will not have libclntsh.so, which in turns means you will not be able to connect to an Oracle Database programmatically.

As suggested in a comment you may get some help from a StackOverflow question/answer, Python3 cx-Oracle Oracle Client library cannot be loaded: “libclntsh.so” on Linux, although this does presuppose that you have actually installed one of the three entities you appear not to want to install.

  • roaima . We have Oracle Database installation but still i am getting this issue. – Arya Aug 20 '19 at 21:19
  • Then you need to do what the page referenced by the error message tells you to do. – roaima Aug 20 '19 at 22:08
  • Yes i have followed the same steps which is not helping me. We dont have chance to install Instant client but as we have our oracle complete database is that possible without Instant client i can connect and execute the queries ? – Arya Aug 21 '19 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.