How To Install Cx_oracle On El Capitan
Solution 1:
I attempted the above and got the following error while trying to install cx_Oracle using Oracle instantclient 12.1:
[535]: /opt/instantclient_12_1 $ python -c "import cx_Oracle"Traceback (most recent call last):
File"<string>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/cx_Oracle.so, 2):
Library not loaded: @rpath/libclntsh.dylib.12.1Referencedfrom: /Library/Python/2.7/site-packages/cx_Oracle.soReason: image not found
Notice the @rpath in the error - it turns out that when building the cx_Oracle library (for instantclient 12.1) on El Capitan, the gcc compiler expects the -rpath flag to be set to know where to find the aforementioned dynamically linked libraries (*.dylib). By default, on instantclient 12.1, pip does not do this for you.
# Set -rpath option before installing...this will use $ORACLE_HOME during compilationexport FORCE_RPATH=TRUE
pip install cx_Oracle
# And verify cx_Oracle was correctly installed
python -c "import cx_Oracle"# If this line fails install cx_Oracle with:# pip install --no-cache-dir --allow-external --allow-unverified cx_oracle
The python -c "import cx_Oracle"
should report no errors.
For a complete install guide (including instantclient download and configuration) check out my post at http://thelaziestprogrammer.com/sharrington/databases/oracle/install-cx_oracle-mac for details.
Solution 2:
Thanks for the instructions Greg.
I had to create a symbolic link for my cx_Oracle pip install to work (using the arguments you provided above). You may want to add these to your instructions.
ln -s libclntsh.dylib.11.1 libclntsh.dylib
I also created another link for libocci as suggested from this install guide: https://gist.github.com/thom-nic/6011715
ln -s libocci.dylib.11.1 libocci.dylib
Solution 3:
I think I fixed it. Basically everything in my steps posted above were correct.
But I ended up using this for the pip install to make sure it pulls down a new copy and rebuilds (and maybe gets a later version??)
$ pip install --no-cache-dir--allow-external--allow-unverified cx_oracle
I was then able to import cx_oracle without issues but I was getting an error "'ORA-21561: OID generation failed'" when connecting to the external server.
Then I followed the instructions here and added a line with my host name to the /etc/hosts file and it all works now.
e.g., added a line like this at the end of /etc/hosts
127.0.0.1 localhost my-host-name
Solution 4:
To install cx_Oracle on OS X, download the 64 bit Instant Client basic & sdk packages for OS X from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html. With this version of Instant Client you can connect to 10g, 11g and 12c databases. This version is linked in a way to avoid the SIP problem Apple recently introduced (which affected Instant Client 11.2).
Then run something like:
unzip instantclient-basic-macos.x64-12.1.0.2.0.zip
unzip instantclient-sdk-macos.x64-12.1.0.2.0.zip
cd instantclient_12_1
ln -s libclntsh.dylib.12.1 libclntsh.dylib
cd ..
export ORACLE_HOME=`pwd`/instantclient_12_1
export FORCE_RPATH=1
pip install cx_Oracle
You may or may not need other pip options, as mentioned in https://stackoverflow.com/a/33284974/4799035
Solution 5:
Also notice: if your python run as 32 bit, and installed cx_Oracle as 64 bit, you will also meet this issue. To avoid this issue, always run your command as super user 'su' and get clear 'su' python is 32 bit or 64 bit. check your python bit How do I determine if my python shell is executing in 32bit or 64bit mode on OS X?
force using 64bit run:
arch -x86_64 /usr/bin/python27
force using 32bit run :
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
Post a Comment for "How To Install Cx_oracle On El Capitan"