Install cx-Oracle on Mavericks
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:
- Download
instantclient-basic-macos.x64-11.2.0.4.0.zip
andinstantclient-sdk-macos.x64-11.2.0.4.0.zip
from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html. - Download the cx-Oracle source code from http://cx-oracle.sourceforge.net.
-
Create a new directory to place the Oracle client files.
mkdir -p /opt/oracle/
- Move
instantclient-basic-macos.x64-11.2.0.4.0.zip
andinstantclient-sdk-macos.x64-11.2.0.4.0.zip
into the folder/opt/oracle/
. -
cd into
/opt/oracle
, unzip the two package.cd /opt/oracle/ unzip instantclient-basic-macos.x64-11.2.0.4.0.zip unzip instantclient-sdk-macos.x64-11.2.0.4.0.zip
-
cd into
instantclient_11_2/sdk
, unzip the packageottclasses.zip
.cd instantclient112/sdk unzip ottclasses.zip
-
Copy some files.
cd /opt/oracle/ cp -R ./sdk/* . cp -R ./sdk/include/* .
-
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
-
Edit
~/.bash_profile
, add these lines.export ORACLE_HOME=/opt/opracle/instantclient_11_2 export DYLD_LIBRARY_PATH=$ORACLE_HOME export LD_LIBRARY_PATH=$ORACLE_HOME
then source it.
source ~/.bash_profile
-
Now we have installed the Oracle client, it's cx-Oracle's turn.
tar -xzvf cxOracle-5.1.2.tar.gz cd cxOracle-5.1.2.tar.gz sudo python setup.py build sudo python setup.py install
-
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.