cx_Oracle Install - The Easy Way on Windows


Install cx_Oracle for use with Python 3.5 on Windows systems. Avoid as much complexity as possible :)

1) Download and unzip the latest 12c Instant Client

Visit the Instant Client Download page and download the correct instant client for your OS. Bitness is important - match to your OS (32 or 64). Unzip the instant client into a directory of your choosing.

Even though I already had a full 12c client installed i was having some issues and using Instant Client got me working.

2) Add Instant Client directory to your path

I unzipped the Instant Client files in C:\dev\instantclient_12_1 but you can use any directory you like.

In Windows navigate to My Computer -> Properties ->Advanced System Settings -> Edit Environment Variables. Under "System Variables" select Path and edit it.

Add a semicolon to the end of the string and add your path.

3) Locate and download a compiled version of cx_Oracle

A lot of the hangup for installing cx_Oracle on Windows is compiling it. Luckily some generous folks have compiled for common Python/OS Version combinations and made the packages available to everyone.

Visit this site to see if there is an appropriate version available for your setup:

I chose cx_Oracle-5.2.1+oci12c-cp35-none-win32.whl for my fresh install of Python 3.5 with 32-bit windows.

4) Install the downloaded file

The packages are distributed as Python Wheel distributions. Run the following command to install (substitute the filename you downloaded above):
pip install cx_Oracle-5.2.1+oci12c-cp35-none-win32.whl

5) Test it...

Here is a simple script that will connect to an existing database user and determine what version the target database is.
import cx_Oracle
con = cx_Oracle.connect('username/password@host:port/sid')
If this runs without errors then you are good to go!