如何在El Capitan上安装cx_Oracle

前端之家收集整理的这篇文章主要介绍了如何在El Capitan上安装cx_Oracle前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
据我了解,有一些与SIP有关的变化使得安装这一点变得困难.

这些页面有安装的背景和建议. http://sourceforge.net/p/cx-oracle/mailman/message/34534872/,http://stefanoapostolico.com/2015/10/08/install_cx_oracle_with_sip_enabled.html

把所有这些放在一起,这是我最好的把它安装到我的virtualenv,但唉,仍然没有好处.

我得到的错误是:

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

以下是我的所有安装步骤:

$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>",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
尝试使用Oracle instantclient 12.1尝试安装cx_Oracle时,我尝试了上述操作并出现以下错误
[535]: /opt/instantclient_12_1 $python -c "import cx_Oracle"
Traceback (most recent call last):
  File "<string>",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

注意错误中的@rpath – 事实证明,当在El Capitan上构建cx_Oracle库(对于instantclient 12.1)时,gcc编译器需要设置-rpath标志以知道在哪里找到上述动态链接库(*. dylib).默认情况下,在instantclient 12.1上,pip不会为您执行此操作.

# 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”应该报告没有错误.

有关完整的安装指南(包括即时客户端下载和配置),请查看我在http://thelaziestprogrammer.com/sharrington/databases/oracle/install-cx_oracle-mac的帖子了解详细信息.

原文链接:https://www.f2er.com/oracle/242105.html

猜你在找的Oracle相关文章