简体   繁体   English

cx_Oracle 8 安装 (macOS Big Sur)

[英]cx_Oracle 8 Installation (macOS Big Sur)

Issue Statement:问题声明:

I am currently working on macOS Big Sur and trying to run and install cx_Oracle 8 on macOs Big Sur .我目前正在开发macOS Big Sur并尝试在 macOS Big Sur上运行和安装cx_Oracle 8 After following the steps listed out on the documentation, I am still receiving the following error upon startup.遵循文档中列出的步骤后,我在启动时仍然收到以下错误。

2022-01-28 10:20:27,085 - root - ERROR - MainThread - 4488076800 - Oracle-Error-Code:0
2022-01-28 10:20:27,086 - root - ERROR - MainThread - 4488076800 - Oracle-Error-Message:DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): no suitable image found.

NOTE: I have of course installed the package pip install cx-Oracle and am importing appropriately import cx_Oracle注意:我当然已经安装了package pip install cx-Oracle并且正在正确import cx_Oracle

What I've tried?我试过什么?

I've tried the following with no luck我试过以下没有运气

Extract the instant client into /opt/oracle/instantclient_19_8将即时客户端提取到/opt/oracle/instantclient_19_8

$ ln -s /opt/oracle/instantclient_19_8/libclntsh.dylib /usr/local/lib/

And

mkdir ~/lib
ln -s /opt/oracle/instantclient_19_8/libclntsh.dylib ~/lib/

I do get a promising error, with these, but, I am at a loss, on what to 'try' next有了这些,我确实得到了一个有希望的错误,但是,我不知道接下来要“尝试”什么

Did find:
    /xxx/xxx/lib/libclntsh.dylib: stat() failed with errno=62". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
enter code here

Work Around解决问题

I do have a work around, which involves, adding in a init with a link to my downloaded client, which as you can image is not ideal, as you have to take in and out for each repo, as needed and would never want to commit this to git when the time comes.我确实有一个解决方法,其中涉及添加一个带有指向我下载客户端的链接的 init,正如您所想象的那样,这并不理想,因为您必须根据需要为每个 repo 进出,并且永远不会想要时机成熟时将此提交给 git。

import cx_Oracle

cx_Oracle.init_oracle_client(lib_dir=f'/xxx/xxx/xxx/instantclient_19_8')

macOS has clamped down on the use of libraries, which is a pain. macOS 限制了库的使用,这很痛苦。

There are two solutions on macOS: macOS 上有两种解决方案:

  • Use cx_Oracle.init_oracle_client() as you found.如您所见,使用cx_Oracle.init_oracle_client() I tend to write it like:我倾向于这样写:
if platform.system() == "Darwin":
 cx_Oracle.init_oracle_client(lib_dir=os.environ.get("HOME")+"/Downloads/instantclient_19_8")
  • Create a sym link like:创建一个符号链接,如:
cjones@mac:~$ python
Python 3.9.6 (default, Aug 20 2021, 13:36:17) 
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> cx_Oracle
<module 'cx_Oracle' from '/Users/cjones/.pyenv/versions/3.9.6/lib/python3.9/site-packages/cx_Oracle.cpython-39-darwin.so'>
>>> 
cjones@mac:~$ ln -s ~/Downloads/instantclient_19_8/libclntsh.dylib /Users/cjones/.pyenv/versions/3.9.6/lib/python3.9/site-packages/

When Oracle releases a 'thin' Python driver you won't need Instant Client and won't need to do either of these.当 Oracle 发布“瘦” Python 驱动程序时,您将不需要 Instant Client,也不需要执行其中任何一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM