Taimoor Pasha
Taimoor Pasha

Reputation: 310

64-bit Oracle Client library cannot be loaded in mac

I have created a sample Python script for Oracle Database connectivity for running queries for Database testing, I have ran the same script on Windows and its running fine but while running on Mac, its showing me this exception again and again.

cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "dlopen(libclntsh.dylib, 1): image not found". See https://oracle.github.io/odpi/doc/installation.html#macos for help

I have changed my Environmental Variable on bash_profile like these:

export ORACLE_HOME= /opt/oracle/instantclient_12_2/
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$ORACLE_HOME:$PATH

Still not working. Can someone help me here. Thanks

Upvotes: 1

Views: 13988

Answers (1)

Christopher Jones
Christopher Jones

Reputation: 10586

From the Installation Instructions make sure you are not using the default Python binary. (Update: use the latest version of cx_Oracle, now called python-oracledb, see these Installation Instructions. On recent macOS versions, it can be used with the default python3 executable on macOS Intel and M1/M2).

Then install cx_Oracle on the new python, as you already know how.

Update: the following steps are out of date for current versions of Instant Client. Just follow the installation instruction link above.

Finally, make sure Instant Client is unzipped and configured:

mkdir ~/lib
ln -s /opt/oracle/instantclient_12_2/libclntsh.dylib ~/lib/

There's no point setting DYLD_LIBRARY_PATH since macOS's SIP protection stops it working. There hasn't been a need to set ORACLE_HOME for cx_Oracle since the cx_Oracle 5 days. And LD_LIBRARY_PATH is mostly a UNIX thing, so don't set that either.

Upvotes: 4

Related Questions