News, tips, partners, and perspectives for the Oracle Linux operating system and upstream Linux kernel work

Installing cx_Oracle and Oracle Instant Client via Oracle Linux Yum Server

Note: this post was updated on 30 january, 2019 to include simplified installation of Oracle Instant Client via Oracle Linux yum server.

cx_Oracle enables access to Oracle Database from Python and conforms with the Python database API specification. The module works with Oracle Database 11g and 12c and both Python 2.x and 3.x. We have just released the first RPM builds of cx_Oracle on the Oracle Linux yum server, including the latest cx_Oracle 7.0.  You can find them in  the Oracle Linux 7 (x86_64) Development  (ol7_developer) and Oracle Linux 6 (x86_64) Development (ol6_developer)

This post covers the steps to install and set up cx_Oracle 7.0 with the default Python 2.7.5 on Oracle Linux 7.  I used our latest Oracle Linux 7 Vagrant box 

1. Confirm Yum Configuration

First, verify your Oracle Linux yum server configuration as we've recently made some changes in the way repository definitions are delivered. Follow the steps here to verify your setup.

2. Install Appropriate Release Packages for Instant Client and cx_Oracle

Once you've verified your yum configuration, install the oracle-release-el7 and oraclelinux-developer-release-el7 release packages to set up yum repository access for Oracle Instant Client and cx_Oracle.

$ sudo yum -y install oracle-release-el7 oraclelinux-developer-release-el7

3. Install cx_Oracle RPM

Note that case matters here. The RPM is called python-cx_Oracle

sudo yum -y install python-cx_Oracle
Running transaction
  Installing : oracle-instantclient18.3-basic-                                                               1/2 
  Installing : python-cx_Oracle-7.0-1.0.1.el7.x86_64                                                                            2/2 
  Verifying  : python-cx_Oracle-7.0-1.0.1.el7.x86_64                                                                            1/2 
  Verifying  : oracle-instantclient18.3-basic-                                                               2/2 

  python-cx_Oracle.x86_64 0:7.0-1.0.1.el7                                                                                           

Dependency Installed:
  oracle-instantclient18.3-basic.x86_64 0:                                                                              


4. Add the Oracle Instant Client to the Runtime Link Path

cx_Oracle depends on Oracle Instant Client. During OpenWorld 2018 we released Oracle Instant Client 18.3 RPMs on Oracle Linux yum server in the ol7_oracle_instantclient and ol6_oracle_instantclient repositories, making installation a breeze. Assuming you have enabled the repository for Oracle Instant Client appropriate for your Oracle Linux release, it is installed as a dependency. Older releases of Oracle Instant Client are available on OTN.


Oracle Instant Client was installed as a dependency of cx_Oracle in the previous step. Before you can make use of Oracle Instant Client, set the runtime link path so that cx_Oracle can find the libraries it needs to connect to Oracle Database.

$ sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
$ sudo ldconfig

5. Test connection to Oracle Database

$ python
Python 2.7.5 (default, Nov  1 2018, 03:12:47) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36.0.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> db = cx_Oracle.connect("scott/tiger@")
>>> db.version

These cx_Oracle RPMs offer Python-on-Oracle developers a quick and straightforward way to get started. Give it a try and let us know what you think in the comments or in the Python and Oracle Developer Community

Read on...

In this next post I go into more detail about what the different cx_Oracle RPMs are for and I show how to install our cx_Oracle RPM on Oracle Linux 6 to connect Python 3.5 to Oracle Database. See this page information about Python on Oracle Linux

Join the discussion

Comments ( 3 )
  • Sulman Thursday, August 27, 2020
    Very helpful thanks
  • Borges Sunday, February 14, 2021
    Bem util. Favor, podem me dizer se já tem uma versão do cx_Oracle para ser usada com o Oracle database 19c e Oracle Linux 8 ??
  • Sergio Wednesday, March 10, 2021
    @Borges: python36-cx_Oracle for Oracle Linux 8 was just released. To install:

    sudo dnf install oracle-instantclient-release-el8
    sudo dnf install python36-cx_Oracle
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.