Skip to content

Instantly share code, notes, and snippets.

@hmartos
Forked from thom-nic/cx_oracle_instructions.md
Last active March 29, 2017 10:48
Show Gist options
  • Save hmartos/9e951576d028dccd4f48c5657c361020 to your computer and use it in GitHub Desktop.
Save hmartos/9e951576d028dccd4f48c5657c361020 to your computer and use it in GitHub Desktop.
Installing CX Oracle (5.2.1) for Python (3.4.4) & Mac OS X (Sierra)

Installing cx_Oracle for Python/ Mac OSX

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

Unzip downloaded files and after unzipping the download, move the sdk directory into the instantclient_11_2 directory

Create a directory /usr/local/share/oracle, copy instantclient_11_2 here and edit for .bash_profile file adding following exports:

export ORACLE_HOME=/usr/local/share/oracle/instantclient_11_2
export DYLD_LIBRARY_PATH=$ORACLE_HOME/
export LD_LIBRARY_PATH=$ORACLE_HOME/
export VERSION=11.2.0.4.0
export ARCH=x86_64
export FORCE_RPATH=1

Reopen terminal or open a new tab to load environment variables. You can check they are loaded executing:

echo $ORACLE_HOME
echo $DYLD_LIBRARY_PATH
echo $ARCH

Create symbolic links for libclntsh.dylib.11.1 and libocci.dylib.11.1

cd $ORACLE_HOME
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib

Download cx_Oracle from PyPI, copy it to $ORACLE_HOME directory and extract it

cd $ORACLE_HOME
tar -xzf cx_Oracle-5.2.1.tar.gz
cd cx_Oracle-5.2.1

env ARCHFLAGS="-arch $ARCH" python3 setup.py build
python setup.py install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment