installing cx_oracle under ubuntu 10.10

If you plan on writing any python applications/scripts for performing any basic SQL query’s against an oracle database you will need to have the cx_oracle library files installed to your machine (or server) here are some quick instructions on how to install them.

Please be aware i have only tested these instructions under Ubuntu 10.10 (32bit) using the 11.2 oracle instant client, when I have time I will try and install this on one of the x86_64 machines i have access to.

  1. become root user
    sudo su -
  1. install python-setuptools python-dev needed for the easy_install later on.
    apt-get install python-setuptools python-dev
  1. install the following from the oracle website http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
  • instantclient-basic-linux (32bit or 64bit depending on your system)
  • instantclient-sdk-linux (32bit or 64bit depending on your system) I have installed the files to /opt/instantclient_11_2 for ease
  1. Setup ORACLE_HOME and LD_LIBRARY_PATH e.g.
    export ORACLE_HOME=/opt/instantclient_11_2
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
  1. The cx_oracle file needs to find a certain library file libclntsh.so you will find this under /opt/instantclient_11_2/libclntsh.so.X.X (X = version number) please make a symlink as follows
    cd $ORACLE_HOME
    ln -s libclntsh.so.11.1 libclntsh.so
  1. run the following from the command line as root
    easy_install cx_oracle
  1. job done.

Here is a good tutoral on how to use the library files once you have things installed

http://www.orafaq.com/wiki/Python

Share