Dependent module /app/oracle/product/19.3.0.0/client_1/lib/libclntsh.so could not be loaded
Installed 19c client to run an application but we are getting below error for the application connectivity.
The python-oracledb driver is a Python programming language extension module allowing Python programs to connect to Oracle Database. Python-oracledb is the new name for Oracle's popular cx_Oracle driver.
Quick Start: Developing Python Applications for Oracle Autonomous Database: Instructions for Windows, macOS, and Linux for installing python-oracledb and connecting to an existing Oracle Autonomous Database.
Thick mode: Some advanced Oracle Database functionality is currently only available via Oracle Client libraries. You can install these libraries using the free Oracle Instant Client packages. Python-oracledb works with Oracle Client libraries 11.2 through 23. See Enabling python-oracledb Thick mode.
Thick mode: Connects to Oracle Database 9.2, 10, 11.2, 12, 18, 21 and 23, depending on the Oracle Client library version. Oracle Database's standard client-server version interoperability allows connection to both older and newer databases. For example, when python-oracledb uses Oracle Client 19 libraries, it can connect to Oracle Database 11.2 or later.
Your application must call the functionoracledb.init_oracle_client(). For example, if the Oracle InstantClient libraries are in C:\oracle\instantclient_19_17 on Windows or$HOME/Downloads/instantclient_19_8 on macOS (Intel x86), then you canuse:
More details and options are shown in the later sectionsEnabling python-oracledb Thick Mode on Windows, Enabling python-oracledb Thick Mode on macOS, and Enabling python-oracledb Thick Mode on Linux and Related Platforms.
If you call init_oracle_client() with a lib_dir parameter,the Oracle Client libraries are loaded immediately from that directory. Ifyou call init_oracle_client() but do not set the lib_dirparameter, the Oracle Client libraries are loaded immediately using thesearch heuristics discussed in later sections.
If Oracle Client libraries cannot be loaded theninit_oracle_client() will raise an error DPI-1047:Oracle Client library cannot be loaded. To resolve this, review theplatform-specific instructions below or see Error Messages.Alternatively, remove the call to init_oracle_client() anduse Thin mode. The features supported by Thin mode can be found inAppendix B: Differences between python-oracledb Thin and Thick Modes.
On any operating system, if you set lib_dir to the library directory of afull database or full client installation (such as from runningrunInstaller), you will need to have previously set the Oracle environment,for example by setting the ORACLE_HOME environment variable. Otherwise youwill get errors like ORA-1804. You should set this variable, and otherOracle environment variables, before starting Python, as shown in OracleEnvironment Variables.
You can find the directory containing the Thick mode binary module by callingthe python CLI without specifying a Python script, executing importoracledb, and then typing oracledb at the prompt. For example thismight show/Users/yourname/.pyenv/versions/3.9.6/lib/python3.9/site-packages/oracledb/__init__.py.After checking that/Users/yourname/.pyenv/versions/3.9.6/lib/python3.9/site-packages/oracledbcontains the binary module thick_impl.cpython-39-darwin.so you could thenrun these commands in a terminal window:
If python-oracledb does not find the Oracle Client library in that directory,the directories on the system library search path may be used, for example,/lib/ and /usr/local/lib, or in $DYLD_LIBRARY_PATH. These pathswill vary with macOS version and Python version. Any value inDYLD_LIBRARY_PATH will not propagate to a sub-shell, so do not rely onsetting it.
Oracle Client libraries are looked for in the operating system library searchpath, such as configured with ldconfig or set in the environment variableLD_LIBRARY_PATH. Web servers and other daemons commonly reset environmentvariables so using ldconfig is generally preferred instead. On some UNIXplatforms an OS specific equivalent, such as LIBPATH or SHLIB_PATH, isused instead of LD_LIBRARY_PATH.
If libraries are not found in the system library search path, then librariesin $ORACLE_HOME/lib will be used. Note that the environment variableORACLE_HOME should only ever be set when you have a full databaseinstallation or full client installation (such as installed with the OracleGUI installer). It should not be set if you are using Oracle Instant Client. Ifbeing used, ORACLE_HOME and other necessary Oracle environment variablesshould be set before starting Python. See Oracle Environment Variables for python-oracledb Thick Mode.
On Linux, python-oracledb Thick mode will not automatically load Oracle Clientlibrary files from the directory where the python-oracledb binary module islocated. One of the above methods should be used instead.
The sqlnet.ora file is only used in the python-oracledb Thick mode. SeeEnabling python-oracledb Thick mode. In the python-oracledb Thin mode, many of theequivalent settings can be defined as connection time parameters, forexample by using the ConnectParams Class.
When python-oracledb Thick mode uses Oracle Client libraries version 12.1 orlater, an optional client parameter file called oraaccess.xml can be usedto configure some behaviors of those libraries, such as statement caching andprefetching. This can be useful if the application cannot be altered. Thefile is read from the same directory as the Optional Oracle Net ConfigurationFiles.
Some common environment variables that influence python-oracledb are shownbelow. The variables that may be needed depend on how Python is installed, howyou connect to the database, and what optional settings are desired. It isrecommended to set Oracle variables in the environment before calling Python.However, they may also be set in the application with os.putenv() before thefirst connection is established. System environment variables likeLD_LIBRARY_PATH must be set before Python starts.
The library search path for platforms like Linux should include theOracle libraries, for example $ORACLE_HOME/lib or/opt/instantclient_19_18. This variable is not needed if thelibraries are located by an alternative method, such as withldconfig. On other UNIX platforms, you may need to set an OSspecific equivalent such as LIBPATH or SHLIB_PATH.
The directory of optional Oracle Client configuration files such astnsnames.ora and sqlnet.ora. Not needed if the configurationfiles are in a default location or if config_dir was not used inoracledb.init_oracle_client(). See Optional Oracle Net Configuration Files.
The oracledb.init_oracle_client() function allows driver_name anderror_url parameters to be set. These are useful for applications whoseend-users are not aware that python-oracledb is being used. An example ofsetting the parameters is:
The convention for driver_name is to separate the product name from theproduct version by a colon and single blank characters. The value will beshown in Oracle Database views like V$SESSION_CONNECT_INFO. If thisparameter is not specified, then a value like python-oracledb thk : 1.2.0is shown, see Finding the python-oracledb Mode.
The error_url string will be shown in the exception raised ifinit_oracle_client() cannot load the Oracle Client libraries. This allowsapplications that use python-oracledb in Thick mode to refer users toapplication-specific installation instructions. If this value is notspecified, then the Installing python-oracledb URL is used.
Reviewing Appendix A: Oracle Database Features Supported by python-oracledb and Appendix B: Differences between python-oracledb Thin and Thick Modes for code changes thatmay be needed. Also read Toggling between Drivers.
You can validate the python-oracledb mode by querying the CLIENT_DRIVERcolumn of V$SESSION_CONNECT_INFO and verifying if the value of the columnbegins with the text python-oracledb thn. See Finding the python-oracledb Mode.
In the directories on the system library search path, e.g. /lib/ and/usr/local/lib, or in $DYLD_LIBRARY_PATH. These paths will varywith macOS version and Python version. Any value inDYLD_LIBRARY_PATH will not propagate to a sub-shell. If the OracleClient libraries cannot be loaded, then an exception is raised.
If lib_dir was not specified, then Oracle Client libraries are lookedfor in the operating system library search path, such as configured withldconfig or set in the environment variable LD_LIBRARY_PATH. Onsome UNIX platforms an OS specific equivalent, such as LIBPATH orSHLIB_PATH is used instead of LD_LIBRARY_PATH. If the librariesare not found, no exception is raised and the search continues, see nextbullet point.
In $ORACLE_HOME/lib. Note the environment variable ORACLE_HOMEshould only ever be set when you have a full database installation orfull client installation. It should not be set if you are using OracleInstant Client. The ORACLE_HOME variable, and other necessaryvariables, should be set before starting Python. See Oracle Environment Variables. Ifthe Oracle Client libraries cannot be loaded, then an exception israised.
If you call cx_Oracle.init_oracle_client() with a lib_dirparameter, the Oracle Client libraries are loaded immediately from thatdirectory. If you call cx_Oracle.init_oracle_client() but do not setthe lib_dir parameter, the Oracle Client libraries are loaded immediatelyusing the search heuristic above. If you do not callcx_Oracle.init_oracle_client(), then the libraries are loaded using thesearch heuristic when the first cx_Oracle function that depends on thelibraries is called, for example when a connection pool is created. If thereis a problem loading the libraries, then an exception is raised.
Applications can call the function cx_Oracle.init_oracle_client() tospecify the directory containing Oracle Instant Client libraries. The OracleClient Libraries are loaded when init_oracle_client() is called. Forexample, if the Oracle Instant Client Libraries are inC:\oracle\instantclient_19_9 on Windows or$HOME/Downloads/instantclient_19_8 on macOS, then you can use:
760c119bf3