Wednesday, August 21, 2013

How to install ox_Oracle in RHEL 64 bit and get it working

Ok this sucked... but it is done now and hopefully this helps one person somewhere, please comment if it does.

So this is the version of RHEL I am using when I call uname -or
2.6.32-358.el6.x86_64 GNU/Linux

I didn't know what version of Oracle was running and so rather than asking the DBA I just ran this SQL statement in my developer tool: "Select * from v$version;"

which told me So then I went over to Oracle's website for 64bit drivers:  (select the license agreement and download to /tmp/)

and download the basic 10.2.04 rpm to my /tmp/ folder

cd /tmp/
rpm -ivh oracle-instantclient-basic-

after that was installed I needed to setup the environmental variables just right. If you don't do this your ox_Oracle install will fail silently and you will hit your head against the wall forever..

Tkae note your exact paths might be a little different so check them (incase you have a different version or didn't do the 64bit, etc..

echo export LD_LIBRARY_PATH=/usr/lib/oracle/ >> ~/.bashrc
echo export ORACLE_HOME=/usr/lib/oracle/ >> ~/.bashrc
echo export PATH=$ORACLE_HOME/bin:$PATH >> ~/.bashrc

This also throws them into the bashrc so they will be there next time. Now it is time to download the ox_Oracle RPM for python. For that go here:

Even though I am using RHEL you can just use the CENTOS RPM. So pick your version of oracle and python. If you don't know your version of python run: python -V


Now install

rpm -ivh cx_Oracle-5.1-10g-py26-1.x86_64.rpm

Yay!! You did it! You are awesome! You saved hours and hours of time compared to everyone else that has tried this! Congrats, you are a genius, epic genius. Well... maybe... to really know if all of this is true try this:

python -c "import cx_Oracle"

If that works with no errors you did it! Now for some more robust testing try actually doing a simple select statement. Let's try the one we started with. Make a file called and put this in it.


Once that opens then copy this in, and of course populate with your connection info. Then save.

import sys
import cx_Oracle

dsn = cx_Oracle.makedsn(host, 1521, sid)
con = cx_Oracle.connect(username+'/'+password+'@' + dsn)
cur = con.cursor()

cur.execute('Select * from v$version')
for result in cur:
    print result
print con.version

print "I am awesome!"

and test



over.unity said...

you are awesome!
great, thank you!

ajax78 said...

Thanks a lot for tutorial.

live n let live said...

From which user I need to run this ? As I tried from root user. It failed

live n let live said...

From any try ending up this : distutils.errors.DistutilsSetupError: cannot locate Oracle include files

Can u guide please ..

Yulia Ivashko said...

You saved me a lot of time