19 April 2012

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
1sudo su -
2. install python-setuptools python-dev needed for the easy_install later on.
1apt-get install python-setuptools python-dev
3. 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
3. Setup ORACLE_HOME and LD_LIBRARY_PATH e.g.
       mkdir /opt/instantclient_11_2

1export ORACLE_HOME=/opt/instantclient_11_2
2export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
4. 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
1cd $ORACLE_HOME
2ln -s libclntsh.so.11.1 libclntsh.so
5. run the following from the command line as root
1easy_install cx_oracle
6. job done.
Here is a good tutoral on how to use the library files once you have things installed

No comments:

Post a Comment