How to install cx_Oracle on El Capitan

As I understand it, there have been some changes related to SIP that make installation difficult.

These pages have help and installation tips. http://sourceforge.net/p/cx-oracle/mailman/message/34534872/ , http://stefanoapostolico.com/2015/10/08/install_cx_oracle_with_sip_enabled.html

Putting it all together, here is my best shot when installing it on my virtualenv, but, alas, it’s all the same good.

The error I am getting is:

Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: dlopen(/Users/me/sx_direct_env/lib/python2.7/site-packages/cx_Oracle.so, 2): Library not loaded: /b/227/rdbms/lib/libclntsh.dylib.10.1 Referenced from: /Users/me/sx_direct_env/lib/python2.7/site-packages/cx_Oracle.so Reason: image not found 

Here are all my installation steps:

 $ cd /Users/me/sx_direct_env/lib/python2.7 $ mkdir oracle $ cd oracle $ export ORACLE_HOME=$PWD $ export DYLD_LIBRARY_PATH=$ORACLE_HOME $ export LD_LIBRARY_PATH=$ORACLE_HOME $ export PATH=$PATH:$ORACLE_HOME $ unzip ~/Downloads/instantclient-basic-macos.x64-11.2.0.4.0.zip $ unzip ~/Downloads/instantclient-sdk-macos.x64-11.2.0.4.0.zip $ mv instantclient_11_2/* . $ rmdir instantclient_11_2 $ curl -O https://raw.githubusercontent.com/kubo/fix_oralib_osx/master/fix_oralib.rb $ ruby -a fix_oralib.rb adrci: add rpath: @loader_path change install name from: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 to: @rpath/libclntsh.dylib.11.1 change install name from: /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib to: @rpath/libnnz11.dylib genezi: add rpath: @loader_path change install name from: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 to: @rpath/libclntsh.dylib.11.1 libclntsh.dylib.11.1: add rpath: @loader_path change identification name from: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 to: @rpath/libclntsh.dylib.11.1 change install name from: /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib to: @rpath/libnnz11.dylib libnnz11.dylib: change identification name from: /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib to: @rpath/libnnz11.dylib libocci.dylib.11.1: change identification name from: /ade/b/3071542110/oracle/rdbms/lib/libocci.dylib.11.1 to: @rpath/libocci.dylib.11.1 libociei.dylib: add rpath: @loader_path change install name from: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 to: @rpath/libclntsh.dylib.11.1 libocijdbc11.dylib: add rpath: @loader_path change install name from: /ade/b/2475221476/oracle/rdbms/lib/libclntsh.dylib.11.1 to: @rpath/libclntsh.dylib.11.1 change install name from: /ade/b/2475221476/oracle/ldap/lib/libnnz11.dylib to: @rpath/libnnz11.dylib uidrvci: add rpath: @loader_path change install name from: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 to: @rpath/libclntsh.dylib.11.1 change install name from: /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib to: @rpath/libnnz11.dylib $ pip install cx_oracle Collecting cx-oracle Installing collected packages: cx-oracle Successfully installed cx-oracle-5.2 $ python -c "import cx_Oracle" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: dlopen(/Users/me/sx_direct_env/lib/python2.7/site-packages/cx_Oracle.so, 2): Library not loaded: /b/227/rdbms/lib/libclntsh.dylib.10.1 Referenced from: /Users/me/sx_direct_env/lib/python2.7/site-packages/cx_Oracle.so Reason: image not found 
+6
source share
5 answers

I think I fixed it. Basically, everything that was in my actions above was correct.

But I ended up using this to install pip, to make sure it pulled out a new copy and rebuild (and maybe get a later version?)

 $ pip install --no-cache-dir --allow-external --allow-unverified cx_oracle 

Then I was able to import cx_oracle without any problems, but I got the error message "ORA-21561: OID generation failed" when connecting to an external server.

Then I followed the instructions here and added a line with my host name to the / etc / hosts file, and now everything works.

for example, add a line like this at the end of / etc / hosts

127.0.0.1 localhost my-host-name

0
source

I tried to do this and got the following error when 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.1 Referenced from: /Library/Python/2.7/site-packages/cx_Oracle.so Reason: image not found 

Pay attention to @rpath in error - it turns out that when creating 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 search for the above 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 compilation export 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 

python -c "import cx_Oracle" should not report errors.

For complete installation guide (including downloading and configuring instantclient), check out your post at http://thelaziestprogrammer.com/sharrington/databases/oracle/install-cx_oracle-mac .

+8
source

Thanks for Greg's instructions.

I had to create a symlink for my cx_Oracle pip installation to work (using the arguments above). You can add them to your instructions.

 ln -s libclntsh.dylib.11.1 libclntsh.dylib 

I also created another link for libocci suggested in this installation guide: https://gist.github.com/thom-nic/6011715

 ln -s libocci.dylib.11.1 libocci.dylib 
+2
source

To install cx_Oracle on OS X, download the 64-bit Instant Client and OS X base and client packages 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 intended to avoid the SIP issue recently released by Apple (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 stated in fooobar.com/questions/996036 / ...

0
source

Also note: if your python runs as 32 bits and set cx_Oracle as 64 bits, you will also encounter this problem. To avoid this problem, always run your command as the superuser 'su' and get a clear 'su' python 32-bit or 64-bit. check your python bit How to determine if my python shell is running in 32-bit or 64-bit mode in OS X?

using 64 bit launch:

arch -x86_64 / usr / bin / python27

using 32-bit startup:

defaults write com.apple.versioner.python I prefer -32-bit-dub yes

0
source

All Articles