Skip to content Skip to sidebar Skip to footer

Python "dpi-1047 Cannot Locate Dlopen(libclntsh.dylib)" On Macos

I am getting the following error. cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: 'dlopen(libclntsh.dylib, 1): image not found'. One fix that I fo

Solution 1:

My code always does this:

import os
import platform
if platform.system() == "Darwin":
    cx_Oracle.init_oracle_client(lib_dir=os.environ.get("HOME")+"/Downloads/instantclient_19_8")

This is the most convenient solution. If you are getting an 'already initialized' error, then make sure you only call init_oracle_client()once per Python process.

Alternatively you can find your cx_Oracle binary like:

cjones@mac:~$ python
Python 3.9.6 (default, Aug 202021, 13:36:17) 
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type"help", "copyright", "credits"or"license"for more information.
>>> import cx_Oracle
>>> cx_Oracle
<module 'cx_Oracle'from'/Users/cjones/.local/lib/python3.9/site-packages/cx_Oracle.cpython-39-darwin.so'>

and then, in a terminal window, do something like:

ln -s $HOME/Downloads/instantclient_19_8/libclntsh.dylib $HOME/.local/lib/python3.9/site-packages

This is for macOS - any Linux users reading this should be aware this solution won't work on Linux.

The oradiag_xxx directory is for Oracle "client" traces. You can delete this at anytime.

Post a Comment for "Python "dpi-1047 Cannot Locate Dlopen(libclntsh.dylib)" On Macos"