Skip to content

Commit 1d1e171

Browse files
Mention DPI-1047 for SEO. Mention unsafe paths.
1 parent ace0d52 commit 1d1e171

File tree

3 files changed

+100
-45
lines changed

3 files changed

+100
-45
lines changed

doc/src/user_guide/initialization.rst

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,35 @@ Setting the Oracle Client Library Directory
5454
-------------------------------------------
5555

5656
When :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-
7065
See :ref:`installation` for information about installing Oracle Client
7166
libraries.
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

7887
On 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

127136
On 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

180208
On Linux and related platforms, python-oracledb Thick mode can be enabled as
181209
follows:
@@ -207,16 +235,18 @@ follows:
207235
raised.
208236

209237
Ensure 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

221251
Oracle Client Libraries are loaded when :meth:`oracledb.init_oracle_client()`
222252
is 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
225255
directory before Python is invoked.
226256

227257
For 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:\oracle\instantclient_19_14"
271+
d = r"C:\oracle\instantclient_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
245275
treated 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

260290
To 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

doc/src/user_guide/installation.rst

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ To use python-oracledb Thick mode with Oracle Instant Client zip files:
271271
cd /opt/oracle
272272
unzip instantclient-basic-linux.x64-21.6.0.0.0.zip
273273
274+
Note OS restrictions may prevent the opening of Oracle Client libraries
275+
installed in unsafe paths, such as from a user directory. You may need to
276+
install under a directory like ``/opt`` or ``/usr/local``.
277+
274278
3. Install the ``libaio`` package with sudo or as the root user. For example::
275279

276280
sudo yum install libaio
@@ -827,9 +831,14 @@ used to install into a local directory::
827831

828832
python setup.py install --user
829833

834+
.. _troubleshooting:
835+
830836
Troubleshooting
831837
===============
832838

839+
Installation Troubleshooting
840+
----------------------------
841+
833842
If installation fails:
834843

835844
- An error such as ``not a supported wheel on this platform.`` indicates that
@@ -866,6 +875,11 @@ If installation fails:
866875
a subdirectory called "odpi" containing files. If this is missing, review the
867876
section on `Install Using GitHub`_.
868877

878+
.. _runtimetroubleshooting:
879+
880+
Runtime Error Troubleshooting
881+
-----------------------------
882+
869883
If using python-oracledb fails:
870884

871885
- If you have multiple versions of Python installed, ensure that you are
@@ -884,14 +898,19 @@ If using python-oracledb fails:
884898
should be the location of your Oracle Client libraries. Do not pass
885899
this parameter on Linux.
886900

901+
- Check that the Python process has permission to open the Oracle Client
902+
libraries. OS restrictions may prevent the opening of libraries installed
903+
in unsafe paths, such as from a user directory. On Linux you may need to
904+
install the Oracle Client libraries under a directory like ``/opt`` or
905+
``/usr/local``.
906+
887907
- Check if Python and your Oracle Client libraries are both 64-bit or
888908
both 32-bit. The ``DPI-1047`` message will tell you whether the 64-bit
889909
or 32-bit Oracle Client is needed for your Python.
890910

891-
- For Thick mode connections, set the environment variable
892-
``DPI_DEBUG_LEVEL`` to 64 and restart python-oracledb. The trace
893-
messages will show how and where python-oracledb is looking for the
894-
Oracle Client libraries.
911+
- Set the environment variable ``DPI_DEBUG_LEVEL`` to 64 and restart
912+
python-oracledb. The trace messages will show how and where
913+
python-oracledb is looking for the Oracle Client libraries.
895914

896915
At a Windows command prompt, this could be done with::
897916

@@ -919,9 +938,10 @@ If using python-oracledb fails:
919938
been installed.
920939

921940
- On Linux, check if the ``LD_LIBRARY_PATH`` environment variable contains
922-
the Oracle Client library directory. Or, if you are using Oracle
923-
Instant Client, a preferred alternative is to ensure that a file in the
924-
``/etc/ld.so.conf.d`` directory contains the path to the Instant Client
941+
the Oracle Client library directory. Some environments such as web servers
942+
reset environment variables. If you are using Oracle Instant Client, a
943+
preferred alternative to ``LD_LIBRARY_PATH`` is to ensure that a file in
944+
the ``/etc/ld.so.conf.d`` directory contains the path to the Instant Client
925945
directory, and then run ``ldconfig``.
926946

927947
- If you get the error ``DPY-3010: connections to this database server
@@ -931,8 +951,8 @@ If using python-oracledb fails:
931951
:meth:`oracledb.init_oracle_client()` in your code. Alternatively,
932952
upgrade your database.
933953

934-
- If you get the error "``DPI-1072: the Oracle Client library version is
935-
unsupported``", then review the installation requirements. The Thick
954+
- If you get the error ``DPI-1072: the Oracle Client library version is
955+
unsupported``, then review the installation requirements. The Thick
936956
mode of python-oracledb needs Oracle Client libraries 11.2 or later.
937957
Note that version 19 is not supported on Windows 7. Similar steps shown
938958
above for ``DPI-1047`` may help. You may be able to use Thin mode which

src/oracledb/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,6 @@
158158
# basic configuration constants
159159
DRIVER_NAME = "python-oracledb"
160160
INSTALLATION_URL = "https://python-oracledb.readthedocs.io/en/" \
161-
"latest/user_guide/installation.html"
161+
"/latest/user_guide/initialization.html" \
162+
"#setting-the-oracle-client-library-directory"
162163
ENCODING = "UTF-8"

0 commit comments

Comments
 (0)