cx oracle ImportError

前端 未结 2 1891
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 02:24

I followed this tutorial for installing cx_oracle on Mac. After some tweaks it was successful. I was using Mavericks earlier. Then I got an upgrade to El Capitan

相关标签:
2条回答
  • 2020-12-12 02:37

    This is related to the system integrity protection (SIP) changes in El Capitan, which among other things prevents DYLD_LIBRARY_PATH being inherited by spawned processes.

    You can modify the cx_Oracle.so library to use the actual path to the Oracle client library instead of the searched path that no longer works; make sure you have ORACLE_HOME still set to point to your actual instant client location, and also note that the exact path reported by ImportError should be used - the 3071542110 value may vary depending on the version/build of Instant Client you have installed:

    export ORACLE_HOME=/usr/local/lib/share/oracle/installclient_11_2
    
    install_name_tool -change \
      /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 \
      $ORACLE_HOME/libclntsh.dylib.11.1 \
      /Library/Python/2.7/site-packages/cx_Oracle.so
    

    ... but then that library can't find another Oracle one:

    ImportError: dlopen(/Library/Python/2.7/site-packages/cx_Oracle.so, 2): Library not loaded: /ade/b/3071542110/oracle/ldap/lib/libnnz11.dylib
      Referenced from: /usr/local/lib/share/oracle/installclient_11_2/libclntsh.dylib.11.1
      Reason: image not found
    

    So you'd need to change that library too, which you may be less comfortable with:

    install_name_tool -change \
      /ade/b/3071542110/oracle/ldap/lib/libnnz11.dylib \
      $ORACLE_HOME/libnnz11.dylib \
      $ORACLE_HOME/libclntsh.dylib.11.1
    

    Depending on the exact client version/build you may need to make the file writable before running that command, with:

    chmod 755 $ORACLE_HOME/libclntsh.dylib.11.1
    

    With those changes I can run the cx_Oracle tests on El Capitan.

    More into on install_name_change here.


    It looks like the 12c instant client has been built in a way that avoids this issue, so upgrading to that is gong to be simpler than hacking around int he 11g files.

    0 讨论(0)
  • 2020-12-12 02:53

    sample fix with

    ln -s /opt/oracle/product/12.1.0/instantclient_12_1/libclntsh.dylib.12.1 /usr/local/lib/libclntsh.dylib.12.1
    
    0 讨论(0)
提交回复
热议问题