Installation of Python cx_Oracle module for Debian Squeeze

Here is a HOWTO to access an Oracle base with Python.

There are two main ways : by compiling the cx_Oracle module source or transforming into a Debian package an ready-to-install rpm package.

I chose the second way. Download the rpm file suited for “CentOS 5 i386 RPM (Oracle 10g, Python 2.5)” at this address :

Check that the command-line program “alien” is present :

root@localhost:~# alien cx_Oracle-5.0.2-10g-py25-1.i386.rpm

A debian package is created : cx-oracle_5.0.2-2_i386.deb

To install it :

root@localhost:~# dpkg -i cx-oracle_5.0.2-2_i386.deb

To check that the module cx_Oracle is available :

fool@localhost:~$ python

Python 2.5.2 (r252:60911, Jan  4 2009, 17:40:26)
[GCC 4.3.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import cx_Oracle

You can now connect to the database Oracle through Python.

For more information about Python Database API Specification v2.0 :

Python Database API Specification v2.0

The official cx_Oracle documentation :

The official cx_Oracle documentation


2 thoughts on “Installation of Python cx_Oracle module for Debian Squeeze

  1. Thanks for the tip.
    I have a problem (probably a stupid admin thing) and you might be able to help.
    env: I’m using oracle 10g, python 2.6, ubuntu 10.4

    -I have no problem to access the DB via the sql-plus cmd, meaning that the DB is up and working.
    -I do manage to import the cx_Oracle with no warnings/comments/errs.
    But when i call cx_Oracle.connect(‘usr/pw’) i get the err:

    cx_Oracle.OperationalError: ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux Error: 2: No such file or directory

    1. Make sure that all Oracle processes have been started properly. Pay attention to the listener. It must be running too.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.