Assume you've got homebrew installed.
Assume python is installed through
brew install python --universial
Download the following files from Oracle
- instantclient-basic-macos.x64-11.2.0.4.0.zip
- instantclient-sdk-macos.x64-11.2.0.4.0.zip
Install
export ORACLE_HOME=/usr/lib/share/oracle
mkdir -p $ORACLE_HOME
cd $ORACLE_HOME
tar -xzf instantclient-basic-macos.x64-11.2.0.4.0.zip
tar -xzf instantclient-sdk-macos.x64-11.2.0.4.0.zip
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb
ruby fix_oralib.rb --absolute-path
Download source code of cx_Oracle (https://sourceforge.net/projects/cx-oracle/files/5.1.2/)
- cx_Oracle-5.1.2.tar.gz
Install
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
export OCI_LIB_DIR=$ORACLE_HOME
export OCI_INC_DIR=$ORACLE_HOME/sdk/include
mkdir ~/cx
cd ~/cx
tar -xzf cx_Oracle-5.1.2.tar.gz
python setup.py build install
If there is some permission problem during "python setup.py", don't use "sudo" but try to use "chown" to get permission.
echo "127.0.0.1 $(hostname)" | sudo tee -a /etc/hosts
Run python and try to import cx_Oracle
import cx_Oracle
con = cx_Oracle.connect ('username/password@hostname:port/sid')
print(con.version)
con.close()
You may get some UserWarning but that's fine. If there is some error then something is wrong.