Issue
I am trying to establish a connection from a Jupyter Notebook using the following Python code:
!pip install cx_Oracle --upgrade
import cx_Oracle
dsn = cx_Oracle.makedsn("<myhost>", 1521, service_name="<myservice>")
connection = cx_Oracle.connect("<myuser>", "<mypassword>", dsn, encoding="UTF-8")
And get this error:
DatabaseError Traceback (most recent call last) in 1 dsn = cx_Oracle.makedsn("", 1521, service_name="") ----> 2 connection = cx_Oracle.connect("", "", dsn, encoding="UTF-8")
DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
In the link, there is no information on how to install the library in Linux using Python from the Jupyter Notebook. How can I do such an installation?
Solution
[Update: instead of installing Instant Client, try the latest version of cx_Oracle, now called python-oracledb since this doesn't need Oracle Instant Client. Installation is a simple pip
install. See the installation instructions.
Some best-practice notebooks on GitHub are also available.]
For cx_Oracle I strongly expect you'll need to install the Oracle client libraries before starting Jupyter, because the OS library search path needs to contain the client library directory, and you can't set this inside a running process. The ODPI-C link does contain the steps you need to follow. You can install the latest Instant Client ZIP or RPM "Basic" package.
The cx_Oracle installation manual is here.
There are some cx_Oracle notebooks about best-practices on GitHub that may be of interest.
Answered By - Christopher Jones
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.