how to set oracle client library path in python wh

2019-09-21 00:56发布

问题:

i have 2 oracle client installed in linux machine. 10.2 and 12.2. Second one i have to use for cx_oracle and older one is needed for other older implementation which i cant touch.

when i add second 12.2 oracle client library in LD_LIBRARY_PATH path and running simple oracle connection python program, it is giving me below error

cx_Oracle.DatabaseError: DPI-1050: Oracle Client library is at version 10.2 but must be at version 11.2 or higher

How can i use the newer version of client library without touching the old config?

回答1:

Write a shell script that lists the 12.2 Oracle Client library in LD_LIBRARY_PATH before other Oracle libraries, and then invokes Python.

#!/bin/sh
export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
python "$@"