Here are my notes on installing cx_Oracle python module to access Oracle Database 12c. First, you need to download these two packages from Oracle Instant Client site.

  • Instant Client Package - Basic

  • Instant Client Package - SDK

I’ve tried their .rpm packages and it did not work for me on Linux, so I would suggest you use the .zip packages instead.

Once you downloaded these two, unzip them into a single directory (eg: $HOME/apps/instantclient). You then need to follow these instructions to install the module itself.

cd $HOME/apps/instantclient
ln -s
export ORACLE_HOME=$HOME/apps/instantclient

pip install cx_Oracle

Here are some quick python test code to verify cx_Oracle is working.

import cx_Oracle as db
conn = db.connect('zemian', 'Welcome1', dsn)
cur = conn.cursor()
cur.execute('SELECT 1+1')
Using the dsn form above can connect directly to database without the need to setup further entry in Oracle’s tnsnames.ora file.

Optionally installing sqlplus client

The sqlplus is a classic client you may use to connect to the Oracle database. You may install this to perform adhoc query and verify your data. Download the following from the same download site above.

  • Instant Client Package - SQL*Plus

Unzip and then add the following to your PATH

export $ORACLE_HOME/bin:$PATH


For more information, see sqlplus doc

comments powered by Disqus