Skip to content

Instantly share code, notes, and snippets.

@plasx
Last active December 12, 2018 03:15
Show Gist options
  • Save plasx/b6aad8b0626f71ed2904def1f29e2111 to your computer and use it in GitHub Desktop.
Save plasx/b6aad8b0626f71ed2904def1f29e2111 to your computer and use it in GitHub Desktop.
Installing instant client 12 on macOS Sierra

Installing cx_Oracle for Python/ Mac OS Sierra

Portions taken from http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html & https://gist.github.com/thom-nic/6011715

Download the following files from Oracle

instantclient-basic-macos.x64-12.1.0.2.0.zip instantclient-sdk-macos.x64-12.1.0.2.0.zip

Create a directory /usr/local/lib/share/oracle

export ORACLE_HOME=/usr/local/lib/share/oracle
export VERSION=12.1.0.2.0
export ARCH=x86_64
    
mkdir -p $ORACLE_HOME

Copy Instant Client Basic & SDK to /usr/local/lib/share/oracle

cp instantclient-basic-macos.x64-$VERSION.zip $ORACLE_HOME
cp instantclient-sdk-macos.x64-$VERSION.zip $ORACLE_HOME

Unpack both files to that directory:

cd $ORACLE_HOME
tar -xzf instantclient-basic-macos.x64-$VERSION.zip
tar -xzf instantclient-sdk-macos.x64-$VERSION.zip

Create Symbolic links in the instant client folder in /user/local/lib/share/oracle

cd instantclient_12_1
ln -s libclntsh.dylib.12.1 libclntsh.dylib
ln -s libocci.dylib.12.1 libocci.dylib

export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME

now you can get rid of the zip files you downloaded as they aren't needed anymore

cd /usr/local/lib/share/oracle
rm instantclient-basic-macos.x64-$VERSION.zip
rm instantclient-sdk-macos.x64-$VERSION.zip

move all the files & folders outside of /instantclient_12_1 to the parent directory /usr/local/lib/share/oracle

mv  -v $ORACLE_HOME/instantclient_12_1/* /$ORACLE_HOME/
rm -rf instantclient_12_1/

You should be able to install cx_Oracle now.

##Troubleshooting

If you're experiencing cx_Oracle.DatabaseError: ORA-21561: OID generation failed Get the hostname of your computer by typing in terminal

hostname

copy this value and add it to your /etc/hosts file with your favorite text editor(i'm using vi in this case)

vi /etc/hosts

on the line that has 127.0.0.1 localhost at the end of it put a space and enter your hostname given to you earlier. below, you see MYMACSNAME, replace that portion with your hostname you received

127.0.0.1       localhost MYMACSNAME
@faizaantrialx
Copy link

Works for me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment