Install cx-Oracle on Mavericks correctly

Posted by Shawn Ding on July 14, 2014


cx-Oracle is a Python Oracle DB connection package, ealier today I met some trouble installing on my macbook running Mavericks, after hacking I found the means to install it correctly:

  1. Download and from

  2. Download the cx-Oracle source code from

  1. Create a new directory to place the Oracle client files.

    mkdir -p /opt/oracle/

  2. Move and into the folder /opt/oracle/.

  3. cd into /opt/oracle, unzip the two package.

    cd /opt/oracle/ unzip unzip

  4. cd into instantclient_11_2/sdk, unzip the package

    cd instantclient_11_2/sdk unzip

  5. Copy some files.

     cd /opt/oracle/
     cp -R ./sdk/* .
     cp -R ./sdk/include/* .
  6. Make some soft links so that cx-Oracle can correctly recognize the Oracle client.

     ln -s libclntsh.dylib.11.1 libclntsh.dylib
     ln -s libocci.dylib.11.1 libocci.dylib
  7. Edit ~/.bash_profile, add these lines.

     export ORACLE_HOME=/opt/opracle/instantclient_11_2

    then source it.

     source ~/.bash_profile
  8. Now we have installed the Oracle client, it’s cx-Oracle’s turn.

    tar -xzvf cx_Oracle-5.1.2.tar.gz cd cx_Oracle-5.1.2.tar.gz sudo python build sudo python install

  9. Now we can check it out whether cx-Oracle is successfully installed.

    >>> import cx_Oracle
    # If this works without a problem, then cx_Oracle is successfully installed.

If you have any questions, plz let me know in the comments.