Portions taken from http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html (in case that link ever dies.)
Assume you've got homebrew installed.
Download the following files from Oracle
Create a directory /usr/lib/share/oracle
export ORACLE_HOME=/usr/lib/share/oracle
export VERSION=11.2.0.3.0
export ARCH=x86_64
mkdir -p $ORACLE_HOME
Unpack both files to that directory:
cd $ORACLE_HOME
tar -xzf instantclient-basic-$VERSION-macosx-x64.zip
tar -xzf instantclient-sdk-$VERSION-macosx-x64.zip
ln -s libclntsh.dylib.11.2 libclntsh.dylib
ln -s libocci.dylib.11.2 libocci.dylib
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
(Note I did not have to do anything with ottclasses.zip
as suggested in the original utexas instructions.)
Last step is to simply run pip
, you might have to add an arch flag:
env ARCHFLAGS="-arch $ARCH" pip install cx_Oracle
Download cx_Oracle-version.tar.gz from Sourceforge
export CX_ORA_VERSION=5.1.2
tar -xzf cx_Oracle-$CX_ORA_VERSION.tar.gz
cd cx_Oracle-$CX_ORA_VERSION
env ARCHFLAGS="-arch $ARCH" python setup.py build
sudo python setup.py install
Some folks have recommended compiling for 32-bit (i386) instead, although I'm not sure why. 64 bit seems to work for me so YMMV.
Basically:
# compile cx_Oracle for 32-bit (requires downloading 32-bit instantclient sources)
ARCHFLAGS="-arch i386" pip install cx_Oracle
# then make your virtualenv python 32-bit only:
virtualenv .
mv bin/python python.fat
lipo python.fat -remove x86_64 -output bin/python
I am trying to build from source with the 64 bit instant client. tried the same as above but I am getting compiler errors.
LM-SJC-00874420:cx_Oracle-5.1.2 vaidesai$ sudo python setup.py build
running build
running build_ext
building 'cx_Oracle' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/usr/lib/instantclient_11_2/sdk/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cx_Oracle.c -o build/temp.macosx-10.9-intel-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.1.2
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
LM-SJC-00874420:cx_Oracle-5.1.2 vaidesai$
LM-SJC-00874420:cx_Oracle-5.1.2 vaidesai$
Not sure how to bypaas this compilation error. The same exact thing was working fine on my previous old laptop. Moved to Mavericks and started seeing this. Can someone help?
Thank you very much.