@@ -37,7 +37,10 @@ Quick Start cx_Oracle Installation
37
37
==================================
38
38
39
39
- Install `Python <https://www.python.org/downloads >`__ 3, if not already
40
- available. Python 3.5 and higher are supported by cx_Oracle 8.
40
+ available. On macOS you must always install your own Python.
41
+
42
+ Python 3.5 and higher are supported by cx_Oracle 8. For Python 2, use
43
+ cx_Oracle 7.3.
41
44
42
45
- Install cx_Oracle from `PyPI
43
46
<https://pypi.org/project/cx-Oracle/> `__ with:
@@ -50,18 +53,21 @@ Quick Start cx_Oracle Installation
50
53
the source package will be downloaded instead. This will be compiled
51
54
and the resulting binary installed.
52
55
53
- If you are behind a proxy, specify your proxy server:
56
+ The ``--user `` option may be useful, if you don't have permission to write to
57
+ system directories:
54
58
55
59
.. code-block :: shell
56
60
57
- python -m pip install cx_Oracle --proxy=http://proxy.example.com:80 --upgrade
61
+ python -m pip install cx_Oracle --upgrade --user
62
+
63
+ If you are behind a proxy, add a proxy server to the command, for example add
64
+ ``--proxy=http://proxy.example.com:80 ``
58
65
59
66
- Add Oracle 19, 18, 12 or 11.2 client libraries to your operating system
60
67
library search path such as ``PATH `` on Windows or ``LD_LIBRARY_PATH `` on
61
- Linux. On macOS move the files to ``~/lib `` or ``/usr/local/lib ``.
62
- Alternatively, on macOS and Windows, you may prefer to use
63
- :meth: `~cx_Oracle.init_oracle_client() ` in your application to pass the Oracle
64
- Client directory name, see :ref: `libinit `.
68
+ Linux. On macOS use :meth: `~cx_Oracle.init_oracle_client() ` in your
69
+ application to pass the Oracle Client directory name, see :ref: `libinit `.
70
+ This is also usable on Windows.
65
71
66
72
To get the libraries:
67
73
@@ -202,18 +208,22 @@ install cx_Oracle from `PyPI
202
208
203
209
python -m pip install cx_Oracle --upgrade
204
210
205
- If you are behind a proxy, specify your proxy server:
211
+ The ``--user `` option may be useful, if you don't have permission to write to
212
+ system directories:
206
213
207
214
.. code-block :: shell
208
215
209
- python -m pip install cx_Oracle --proxy=http://proxy.example.com:80 --upgrade
216
+ python -m pip install cx_Oracle --upgrade --user
217
+
218
+ If you are behind a proxy, add a proxy server to the command, for example add
219
+ ``--proxy=http://proxy.example.com:80 ``
210
220
211
221
This will download and install a pre-compiled binary `if one is
212
222
available <https://pypi.org/project/cx-Oracle/> `__ for your
213
223
architecture. If a pre-compiled binary is not available, the source
214
224
will be downloaded, compiled, and the resulting binary installed.
215
225
Compiling cx_Oracle requires the ``Python.h `` header file. If you are
216
- using the default python package, this file is in the ``python-devel ``
226
+ using the default `` python `` package, this file is in the ``python-devel ``
217
227
package or equivalent.
218
228
219
229
Install Oracle Client
@@ -291,7 +301,7 @@ To use cx_Oracle with Oracle Instant Client zip files:
291
301
.. code-block :: python
292
302
293
303
import cx_Oracle
294
- cx_Oracle.init_oracle_client(config_dir = " /home/your_username/oracle/your_config_dir" )
304
+ cx_Oracle.init_oracle_client(config_dir = " /home/your_username/oracle/your_config_dir" )
295
305
296
306
Or set the environment variable ``TNS_ADMIN `` to that directory name.
297
307
@@ -358,7 +368,7 @@ To use cx_Oracle with Oracle Instant Client RPMs:
358
368
.. code-block :: python
359
369
360
370
import cx_Oracle
361
- cx_Oracle.init_oracle_client(config_dir = " /opt/oracle/your_config_dir" )
371
+ cx_Oracle.init_oracle_client(config_dir = " /opt/oracle/your_config_dir" )
362
372
363
373
Or set the environment variable ``TNS_ADMIN `` to that directory name.
364
374
@@ -481,26 +491,26 @@ To use cx_Oracle with Oracle Instant Client zip files:
481
491
3. There are several alternative ways to tell cx_Oracle where your Oracle Client
482
492
libraries are, see :ref: `initialization `.
483
493
484
- With Oracle Instant Client you can use :meth: `~cx_Oracle.init_oracle_client() `
485
- in your application:
494
+ * With Oracle Instant Client you can use :meth: `~cx_Oracle.init_oracle_client() `
495
+ in your application, for example :
486
496
487
- .. code-block :: python
497
+ .. code-block :: python
488
498
489
- import cx_Oracle
490
- cx_Oracle.init_oracle_client(lib_dir = " C:\oracle\instantclient_19_6" )
499
+ import cx_Oracle
500
+ cx_Oracle.init_oracle_client(lib_dir = r " C:\o racle\i nstantclient_19_6" )
491
501
492
- Alternatively, add the Oracle Client directory to the ``PATH `` environment
493
- variable. The Instant Client directory must occur in ``PATH `` before any
494
- other Oracle directories. Restart any open command prompt windows.
502
+ * Alternatively, add the Oracle Instant Client directory to the ``PATH ``
503
+ environment variable. The directory must occur in ``PATH `` before any
504
+ other Oracle directories. Restart any open command prompt windows.
495
505
496
- Another way to set ``PATH `` is to use a batch file that sets it before Python
497
- is executed, for example::
506
+ * Another way to set ``PATH `` is to use a batch file that sets it before Python
507
+ is executed, for example::
498
508
499
- REM mypy.bat
500
- SET PATH=C:\oracle\instantclient_19_6;%PATH%
501
- python %*
509
+ REM mypy.bat
510
+ SET PATH=C:\oracle\instantclient_19_6;%PATH%
511
+ python %*
502
512
503
- Invoke this batch file every time you want to run Python.
513
+ Invoke this batch file every time you want to run Python.
504
514
505
515
4. Oracle Instant Client libraries require a Visual Studio redistributable with
506
516
a 64-bit or 32-bit architecture to match Instant Client's architecture.
@@ -519,7 +529,7 @@ To use cx_Oracle with Oracle Instant Client zip files:
519
529
.. code-block :: python
520
530
521
531
import cx_Oracle
522
- cx_Oracle.init_oracle_client(config_dir = " C:\oracle\your_config_dir" )
532
+ cx_Oracle.init_oracle_client(config_dir = r " C:\o racle\y our_config_dir" )
523
533
524
534
Or set the environment variable ``TNS_ADMIN `` to that directory name.
525
535
@@ -550,21 +560,23 @@ Python architecture.
550
560
``network\admin `` subdirectory of the Oracle Database software
551
561
installation.
552
562
553
- Alternatively, use :meth: `~cx_Oracle.init_oracle_client() ` or set
554
- `` TNS_ADMIN `` as shown in the previous section.
563
+ Alternatively, pass `` config_dir `` to :meth: `~cx_Oracle.init_oracle_client() `
564
+ as shown in the previous section, or set `` TNS_ADMIN `` to the directory name .
555
565
556
566
Installing cx_Oracle on macOS
557
567
=============================
558
568
559
569
Install Python
560
570
--------------
561
571
562
- Make sure you are not using the bundled Python. This has restricted
563
- entitlements and will fail to load Oracle client libraries. Instead
564
- use `Homebrew <https://brew.sh >`__ or `Python.org
572
+ Make sure you are not using a bundled Python. These have restricted
573
+ entitlements and will fail to load Oracle client libraries. Instead use
574
+ `Homebrew <https://brew.sh >`__ or `Python.org
565
575
<https://www.python.org/downloads> `__.
566
576
567
577
Note Instant Client 19 and earlier are not supported on macOS 10.15 Catalina.
578
+ You will need to allow access to several Instant Client libraries from the
579
+ Security & Privacy preference pane.
568
580
569
581
Install cx_Oracle
570
582
-----------------
@@ -575,19 +587,19 @@ package to install cx_Oracle from `PyPI
575
587
576
588
python -m pip install cx_Oracle --upgrade
577
589
578
- If you are behind a proxy, specify your proxy server:
590
+ The ``--user `` option may be useful, if you don't have permission to write to
591
+ system directories:
579
592
580
593
.. code-block :: shell
581
594
582
- python -m pip install cx_Oracle --proxy=http://proxy.example.com:80 --upgrade
595
+ python -m pip install cx_Oracle --upgrade --user
583
596
584
- The `` --user `` option may also be useful, if you don't have permission to write
585
- to `` /usr ``.
597
+ If you are behind a proxy, add a proxy server to the command, for example add
598
+ `` --proxy=http://proxy.example.com:80 ``
586
599
587
600
The source will be downloaded, compiled, and the resulting binary
588
601
installed.
589
602
590
-
591
603
Install Oracle Instant Client
592
604
-----------------------------
593
605
@@ -615,64 +627,72 @@ To use cx_Oracle with Oracle Instant Client zip files:
615
627
616
628
This will create a directory ``/Users/your_username/instantclient_19_3 ``.
617
629
618
- 3. There are several alternative ways to tell cx_Oracle where your Oracle Client
619
- libraries are, see :ref: `initialization `.
630
+ 3. There are several alternative ways to tell cx_Oracle where your Oracle
631
+ Instant Client libraries are, see :ref: `initialization `.
620
632
621
- You can use :meth: `~cx_Oracle.init_oracle_client() ` in your
622
- application:
633
+ * You can use :meth: `~cx_Oracle.init_oracle_client() ` in your
634
+ application:
623
635
624
- .. code-block :: python
625
-
626
- import cx_Oracle
627
- cx_Oracle.init_oracle_client(lib_dir = " /Users/your_username/instantclient_19_3" )
636
+ .. code-block :: python
628
637
638
+ import cx_Oracle
639
+ cx_Oracle.init_oracle_client(lib_dir = " /Users/your_username/instantclient_19_3" )
629
640
630
- Alternatively, add a link to ``$HOME/lib `` or ``/usr/local/lib `` to enable
631
- applications to find Instant Client. If the ``lib `` sub-directory does not
632
- exist, you can create it. For example:
633
-
634
- .. code-block :: shell
641
+ * Alternatively, locate the directory with the cx_Oracle module binary and
642
+ link or copy Oracle Instant Client to that directory. For example, if you
643
+ installed cx_Oracle with ``--user `` in Python 3.8, then
644
+ ``cx_Oracle.cpython-38-darwin.so `` might be in
645
+ ``~/Library/Python/3.8/lib/python/site-packages ``. You can then run
646
+ ``ln -s ~/instantclient_19_3/libclntsh.dylib
647
+ ~/Library/Python/3.8/lib/python/site-packages `` or copy the Instant Client
648
+ libraries to that directory.
635
649
636
- mkdir ~ /lib
637
- ln -s ~ /instantclient_19_3/libclntsh.dylib ~ /lib/
650
+ * Alternatively, you can set ``DYLD_LIBRARY_PATH `` to the directory
651
+ containing Oracle Instant Client, however this needs to be set in each
652
+ terminal or process that invokes Python. The variable will not propagate
653
+ to sub-shells.
638
654
639
- If you now run ``ls -l ~/lib/libclntsh.dylib `` you will see something like:
655
+ * Alternatively, on older versions of macOS, you could add a link to
656
+ ``$HOME/lib `` or ``/usr/local/lib `` to enable applications to find Instant
657
+ Client. If the ``lib `` sub-directory does not exist, you can create
658
+ it. For example:
640
659
641
- .. code-block :: text
660
+ .. code-block :: shell
642
661
643
- lrwxr-xr-x 1 your_username staff 48 12 Nov 15:04 /Users/your_username/lib/libclntsh.dylib -> /Users/your_username/instantclient_19_3/libclntsh.dylib
662
+ mkdir ~ /lib
663
+ ln -s ~ /instantclient_19_3/libclntsh.dylib ~ /lib/
644
664
645
- Instead of linking, you can copy the required OCI libraries. For example:
665
+ Instead of linking, you can copy the required OCI libraries. For example:
646
666
647
- .. code-block :: shell
667
+ .. code-block :: shell
648
668
649
- mkdir ~ /lib
650
- cp ~ /instantclient_19_3/{libclntsh.dylib.19.1,libclntshcore.dylib.19.1,libnnz19.dylib,libociei.dylib} ~ /lib/
669
+ mkdir ~ /lib
670
+ cp ~ /instantclient_19_3/{libclntsh.dylib.19.1,libclntshcore.dylib.19.1,libnnz19.dylib,libociei.dylib} ~ /lib/
651
671
652
- For Instant Client 11.2, the OCI libraries must be copied. For example:
672
+ For Instant Client 11.2, the OCI libraries must be copied. For example:
653
673
654
- .. code-block :: shell
674
+ .. code-block :: shell
655
675
656
- mkdir ~ /lib
657
- cp ~ /instantclient_11_2/{libclntsh.dylib.11.1,libnnz11.dylib,libociei.dylib} ~ /lib/
676
+ mkdir ~ /lib
677
+ cp ~ /instantclient_11_2/{libclntsh.dylib.11.1,libnnz11.dylib,libociei.dylib} ~ /lib/
658
678
659
679
4. If you use optional Oracle configuration files such as ``tnsnames.ora ``,
660
- ``sqlnet.ora `` or ``oraaccess.xml `` with Instant Client, then put the files
661
- in an accessible directory, for example in
680
+ ``sqlnet.ora `` or ``oraaccess.xml `` with Oracle Instant Client, then put the
681
+ files in an accessible directory, for example in
662
682
``/Users/your_username/oracle/your_config_dir ``. Then use:
663
683
664
684
.. code-block :: python
665
685
666
686
import cx_Oracle
667
- cx_Oracle.init_oracle_client(config_dir = " /Users/your_username/oracle/your_config_dir" )
687
+ cx_Oracle.init_oracle_client(config_dir = " /Users/your_username/oracle/your_config_dir" )
668
688
669
689
Or set the environment variable ``TNS_ADMIN `` to that directory name.
670
690
671
- Alternatively, put the files in the ``network/admin `` subdirectory of
691
+ Alternatively, put the files in the ``network/admin `` subdirectory of Oracle
672
692
Instant Client, for example in
673
693
``/Users/your_username/instantclient_19_3/network/admin ``. This is the
674
- default Oracle configuration directory for executables linked with
675
- this Instant Client.
694
+ default Oracle configuration directory for executables linked with this
695
+ Instant Client.
676
696
677
697
Installing cx_Oracle without Internet Access
678
698
============================================
0 commit comments