问题
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
回答1:
From the Installation Instructions make sure you are not using the default Python binary.
Then install cx_Oracle on the new python, as you already know how.
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.
来源:https://stackoverflow.com/questions/53098434/64-bit-oracle-client-library-cannot-be-loaded-in-mac