--user
option may be useful, if you don’t have permission to write tosystem directories:--proxy=http://proxy.example.com:80
PATH
on Windows or LD_LIBRARY_PATH
onLinux. On macOS use init_oracle_client()
in yourapplication to pass the Oracle Client directory name, see Locating the Oracle Client Libraries.This is also usable on Windows.
If your database is on a remote computer, then download and unzip the clientlibraries from the free Oracle Instant Client“Basic” or “Basic Light” package for your operating systemarchitecture.Instant Client on Windows requires an appropriate Microsoft WindowsRedistributables, see Installing cx_Oracle on Windows. On Linux, thelibaio
(sometimes calledlibaio1
) package is needed. Oracle Linux 8 alsoneeds thelibnsl
package. Alternatively, use the client libraries already available in alocally installed database such as the free Oracle DatabaseExpress Edition (“XE”)release.
hostname/servicename
, using the hostname where the database isrunning, and using the service name of the Oracle Database instance.clientversion()
can be usedto determine which Oracle Client version is in use and the attributeConnection.version
can be used to determine which OracleDatabase version a connection is accessing. These can then be used toadjust application behavior accordingly. Attempts to use some Oraclefeatures that are not supported by a particular client/servercombination may result in runtime errors. These include:--user
option may be useful, if you don’t have permission to write tosystem directories:--proxy=http://proxy.example.com:80
Python.h
header file. If you areusing the default python
package, this file is in the python-devel
package or equivalent.libaio
package with sudo or as the root user. For example:libaio1
instead.libnsl
package.LD_LIBRARY_PATH
tothe appropriate directory for the Instant Client version. Forexample:tnsnames.ora
,sqlnet.ora
or oraaccess.xml
with Instant Client, then put the filesin an accessible directory, for example in/opt/oracle/your_config_dir
. Then use:TNS_ADMIN
to that directory name.network/admin
subdirectory of InstantClient, for example in /opt/oracle/instantclient_19_9/network/admin
.This is the default Oracle configuration directory for executables linkedwith this Instant Client.libaio
.libnsl
package.LD_LIBRARY_PATH
set to the appropriate directory for theInstant Client version. For example:tnsnames.ora
,sqlnet.ora
or oraaccess.xml
with Instant Client, then put the filesin an accessible directory, for example in/opt/oracle/your_config_dir
. Then use:TNS_ADMIN
to that directory name.network/admin
subdirectory of InstantClient, for example in /usr/lib/oracle/19.9/client64/lib/network/admin
.This is the default Oracle configuration directory for executables linkedwith this Instant Client.tnsnames.ora
,sqlnet.ora
or oraaccess.xml
can be placed in$ORACLE_HOME/network/admin
.TNS_ADMIN
to that directory name.instantclient-basic-windows.x64-19.9.0.0.0dbru.zip
toC:oracleinstantclient_19_9
.
- For Instant Client 19 install VS 2017.
- For Instant Client 18 or 12.2 install VS 2013
- For Instant Client 12.1 install VS 2010
- For Instant Client 11.2 install VS 2005 64-bit or VS 2005 32-bit
init_oracle_client()
in your application, for example:PATH
environment variable. The directory must occur in PATH
before anyother Oracle directories. Restart any open command prompt windows.PATH
is to use a batch file that sets it before Pythonis executed, for example:tnsnames.ora
,sqlnet.ora
or oraaccess.xml
with Instant Client, then put the filesin an accessible directory, for example inC:oracleyour_config_dir
. Then use:TNS_ADMIN
to that directory name.networkadmin
subdirectory ofInstant Client, for example inC:oracleinstantclient_19_9networkadmin
. This is the defaultOracle configuration directory for executables linked with thisInstant Client.PATH
to include the path that containsOCI.DLL
, if it is not already set.tnsnames.ora
,sqlnet.ora
or oraaccess.xml
can be placed in thenetworkadmin
subdirectory of the Oracle Database softwareinstallation.config_dir
to init_oracle_client()
as shown in the previous section, or set TNS_ADMIN
to the directory name.--user
option may be useful, if you don’t have permission to write tosystem directories:--proxy=http://proxy.example.com:80
$HOME/Downloads/instantclient_19_8
.install_ic.sh
once. It will copy all mounted Instant Client DMG packages atthe same time.$HOME/Downloads/instantclient_19_8
.init_oracle_client()
once in your application:tnsnames.ora
,sqlnet.ora
or oraaccess.xml
with Oracle Instant Client, then put thefiles in an accessible directory, for example in/Users/your_username/oracle/your_config_dir
. Then use:TNS_ADMIN
to that directory name.network/admin
subdirectory of OracleInstant Client, for example in/Users/your_username/Downloads/instantclient_19_8/network/admin
. This is thedefault Oracle configuration directory for executables linked with thisInstant Client.NLS_LANG
environment variable isignored. If you need to change the character set, then pass encoding
and nendcoding
parameters when creating a connection or connectionpool. See Character Sets and Globalization.type(var)
need to be changed to var.type
.var.typeisnotNone
need to be changed toisinstance(var.type,cx_Oracle.ObjectType)
TIMESTAMPWITHTIMEZONE
columns will now be reported ascx_Oracle.DB_TYPE_TIMESTAMP_TZ
instead ofcx_Oracle.TIMESTAMP
in Cursor.description
.TIMESTAMPWITHLOCALTIMEZONE
columns will now be reportedas cx_Oracle.DB_TYPE_TIMESTAMP_LTZ
instead ofcx_Oracle.TIMESTAMP
in Cursor.description
.BINARY_FLOAT
columns will now be reported ascx_Oracle.DB_TYPE_BINARY_FLOAT
instead ofcx_Oracle.NATIVE_DOUBLE
in Cursor.description
.ORACLE_HOME
.LD_LIBRARY_PATH
or use ldconfig
tolocate the Oracle client library.cx_Oracle.init_oracle_client()
method and does not support loading theOracle Client libraries from the directory containing the cx_Oracle modulebinary.python-mpipinstallcx-oracle5.3
to install from source.-v
with pip. Review your output and logs. Try to installusing a different method. Google anything that looks like an error.Try some potential solutions.http_proxy
and/or https_proxy
? Ortry pipinstall--proxy=http://proxy.example.com:80cx_Oracle--upgrade
?pipinstallcx_Oracle--upgrade--force-reinstall
pipinstallcx_Oracle--upgrade--user
or venv?Nomodulenamedpip
”? The pip module is builtinto Python but is sometimes removed by the OS. Use the venv module(builtin to Python 3.x) or virtualenv module instead.fatalerror:dpi.h:Nosuchfileordirectory
”when building from source code? Ensure that your source installation hasa subdirectory called “odpi” containing files. If missing, review thesection on Install Using GitHub.DPI-1047:OracleClientlibrarycannotbeloaded
”?init_oracle_client()
.See Using cx_Oracle.init_oracle_client() to set the Oracle Client directory.DPI-1047
message will tell you whether the 64-bitor 32-bit Oracle Client is needed for your Python.DPI_DEBUG_LEVEL
to 64 and restartcx_Oracle. The trace messages will show how and where cx_Oracle islooking for the Oracle Client libraries.init_oracle_client()
and havea full database installation, make sure this database is the currentlyconfigured database.init_oracle_client()
, then restart your command promptand use setPATH
to check the environment variable has the correctOracle Client listed before any other Oracle directories.DIR
command to verify that OCI.DLL
exists inthe directory passed to init_oracle_client()
or set in PATH
.LD_LIBRARY_PATH
environment variable containsthe Oracle Client library directory. If you are using Oracle InstantClient, a preferred alternative is to ensure a file in the/etc/ld.so.conf.d
directory contains the path to the Instant Clientdirectory, and then run ldconfig
.init_oracle_client()
, then put the Oracle InstantClient libraries in ~/lib
or /usr/local/lib
.DPI-1072:theOracleClientlibraryversionisunsupported
”, then review the installation requirements. cx_Oracleneeds Oracle client libraries 11.2 or later. Note that version 19 is notsupported on Windows 7. Similar steps shown above for DPI-1047
mayhelp.