@@ -54,26 +54,35 @@ Setting the Oracle Client Library Directory
5454-------------------------------------------
5555
5656When :meth: `~oracledb.init_oracle_client() ` is called, python-oracledb
57- dynamically loads Oracle Client libraries using a search heuristic. Only the
58- first set of libraries found are loaded. The libraries can be:
57+ dynamically loads Oracle Client libraries using a search heuristic. The
58+ libraries can be:
5959
6060- in an installation of Oracle Instant Client
6161- or in a full Oracle Client installation
6262- or in an Oracle Database installation (if Python is running on the same
6363 machine as the database).
6464
65- The versions of Oracle Client and Oracle Database do not have
66- to be the same. For certified configurations see Oracle Support's `Doc ID
67- 207303.1
68- <https://support.oracle.com/epmos/faces/DocumentDisplay?id=207303.1> `__.
69-
7065See :ref: `installation ` for information about installing Oracle Client
7166libraries.
7267
68+ The versions of Oracle Client libraries and Oracle Database do not have to be
69+ the same. For certified configurations see Oracle Support's `Doc ID 207303.1
70+ <https://support.oracle.com/epmos/faces/DocumentDisplay?id=207303.1> `__.
71+
72+ .. note ::
73+
74+ If Oracle Client libraries cannot be loaded then
75+ :meth: `~oracledb.init_oracle_client() ` will raise an error ``DPI-1047:
76+ Oracle Client library cannot be loaded ``. To resolve this, review the
77+ platform-specific instructions below or see :ref: `runtimetroubleshooting `.
78+ Alternatively remove the call to :meth: `~oracledb.init_oracle_client() ` and
79+ use Thin mode. The features supported by Thin mode can be found in
80+ :ref: `driverdiff `.
81+
7382.. _wininit :
7483
75- Setting the Oracle Client Directory on Windows
76- ++++++++++++++++++++++++++++++++++++++++++++++
84+ Setting the Oracle Client Library Directory on Windows
85+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++
7786
7887On Windows, python-oracledb Thick mode can be enabled as follows:
7988
@@ -121,8 +130,8 @@ On Windows, python-oracledb Thick mode can be enabled as follows:
121130
122131.. _macinit :
123132
124- Setting the Oracle Client Directory on macOS
125- ++++++++++++++++++++++++++++++++++++++++++++
133+ Setting the Oracle Client Library Directory on macOS
134+ ++++++++++++++++++++++++++++++++++++++++++++++++++++
126135
127136On macOS, python-oracledb Thick mode can be enabled as follows:
128137
@@ -154,14 +163,33 @@ On macOS, python-oracledb Thick mode can be enabled as follows:
154163 'Basic' or 'Basic Light' package, or a symbolic link to the main Oracle
155164 Client library if Instant Client is in a different directory.
156165
157- You can find the directory containing the Thick mode binary module by
158- calling the python CLI without specifying a Python script, executing
159- ``import oracledb ``, and then typing ``oracledb `` at the prompt. For
160- example if
161- ``/Users/yourname/Library/3.9.6/lib/python3.9/site-packages/oracledb-1.0.0-py3.9-macosx-11.5-x86_64.egg/oracledb ``
162- contains ``thick_impl.cpython-39-darwin.so ``, then you could run ``ln -s
163- ~/Downloads/instantclient_19_8/libclntsh.dylib
164- ~/Library/3.9.6/lib/python3.9/site-packages/oracledb-1.0.0-py3.9-macosx-11.5-x86_64.egg/oracledb/ ``.
166+ You can find the directory containing the Thick mode binary module by calling
167+ the python CLI without specifying a Python script, executing ``import
168+ oracledb ``, and then typing ``oracledb `` at the prompt. For example this
169+ might show
170+ ``/Users/yourname/.pyenv/versions/3.9.6/lib/python3.9/site-packages/oracledb/__init__.py ``.
171+ After checking that
172+ ``/Users/yourname/.pyenv/versions/3.9.6/lib/python3.9/site-packages/oracledb ``
173+ contains the binary module ``thick_impl.cpython-39-darwin.so `` you could then
174+ run these commands in a terminal window::
175+
176+ CLIENT_DIR=~/Downloads/instantclient_19_8
177+ DPY_DIR=~/.pyenv/versions/3.9.6/lib/python3.9/site-packages/oracledb
178+ ln -s $CLIENT_DIR/libclntsh.dylib $DPY_DIR
179+
180+ This can be automated in Python with:
181+
182+ .. code-block :: python
183+
184+ CLIENT_DIR = " ~/Downloads/instantclient_19_8"
185+ LIB_NAME = " libclntsh.dylib"
186+
187+ import os
188+ import oracledb
189+
190+ target_dir = oracledb.__path__ [0 ]
191+ os.symlink(os.path.join(CLIENT_DIR , LIB_NAME ),
192+ os.path.join(target_dir, LIB_NAME ))
165193
166194 If python-oracledb does not find the Oracle Client library in that
167195 directory, the directories on the system library search path may be used,
@@ -174,8 +202,8 @@ On macOS, python-oracledb Thick mode can be enabled as follows:
174202
175203.. _linuxinit :
176204
177- Setting the Oracle Client Directory on Linux and Related Platforms
178- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
205+ Setting the Oracle Client Library Directory on Linux and Related Platforms
206+ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179207
180208On Linux and related platforms, python-oracledb Thick mode can be enabled as
181209follows:
@@ -207,16 +235,18 @@ follows:
207235 raised.
208236
209237Ensure that the Python process has directory and file access permissions for
210- the Oracle Client libraries. On Linux ensure a ``libclntsh.so `` file exists.
211- On macOS ensure a ``libclntsh.dylib `` file exists. python-oracledb Thick will
212- not directly load ``libclntsh.*.XX.1 `` files in ``lib_dir `` or from the directory
213- where the python-oracledb binary module is available. Note that other libraries
214- used by ``libclntsh* `` are also required.
238+ the Oracle Client libraries. On some platforms OS restrictions may prevent the
239+ opening of Oracle Client libraries installed in unsafe paths, such as from a
240+ user directory. On Linux ensure a ``libclntsh.so `` file exists. On macOS
241+ ensure a ``libclntsh.dylib `` file exists. Python-oracledb Thick mode will not
242+ directly load ``libclntsh.*.XX.1 `` files in ``lib_dir `` or from the directory
243+ where the python-oracledb binary module is available. Note that other
244+ libraries used by ``libclntsh* `` are also required.
215245
216246.. _usinginitoracleclient :
217247
218- Calling oracledb.init_oracle_client() to Set the Oracle Client Directory
219- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
248+ Example Calling oracledb.init_oracle_client()
249+ +++++++++++++++++++++++++++++++++++++++++++++
220250
221251Oracle Client Libraries are loaded when :meth: `oracledb.init_oracle_client() `
222252is called. In some environments, applications can use the ``lib_dir ``
@@ -225,7 +255,7 @@ Otherwise, the system library search path should contain the relevant library
225255directory before Python is invoked.
226256
227257For example, if the Oracle Instant Client Libraries are in
228- ``C:\oracle\instantclient_19_9 `` on Windows or
258+ ``C:\oracle\instantclient_19_17 `` on Windows or
229259``$HOME/Downloads/instantclient_19_8 `` on macOS (Intel x86), then you can use:
230260
231261.. code-block :: python
@@ -238,10 +268,10 @@ For example, if the Oracle Instant Client Libraries are in
238268 if platform.system() == " Darwin" and platform.machine() == " x86_64" :
239269 d = os.environ.get(" HOME" )+ " /Downloads/instantclient_19_8" )
240270 elif platform.system() == " Windows" :
241- d = r " C:\o racle\i nstantclient_19_14 "
271+ d = r " C:\o racle\i nstantclient_19_17 "
242272 oracledb.init_oracle_client(lib_dir = d)
243273
244- Note the use of a 'raw' string ``r"..." `` on Windows so that backslashes are
274+ The use of a 'raw' string ``r"..." `` on Windows means that backslashes are
245275treated as directory separators.
246276
247277**Note that if you set ** ``lib_dir `` **on Linux and related platforms, you must
@@ -258,12 +288,16 @@ shown in :ref:`envset`.
258288**Tracing Oracle Client Libraries Loading **
259289
260290To trace the loading of Oracle Client libraries, the environment variable
261- ``DPI_DEBUG_LEVEL `` can be set to 64 before starting Python. For example, on
262- Linux, you might use::
291+ ``DPI_DEBUG_LEVEL `` can be set to 64 before starting Python. At a Windows
292+ command prompt, this could be done with::
293+
294+ set DPI_DEBUG_LEVEL=64
295+
296+ On Linux and macOS, you might use::
263297
264- $ export DPI_DEBUG_LEVEL=64
265- $ python myapp.py 2> log.txt
298+ export DPI_DEBUG_LEVEL=64
266299
300+ When your python-oracledb application is run, logging output is shown.
267301
268302.. _optnetfiles :
269303
0 commit comments