[英]cx_Oracle 8 Installation (macOS Big Sur)
我目前正在开发macOS Big Sur并尝试在 macOS Big Sur上运行和安装cx_Oracle 8 。 遵循文档中列出的步骤后,我在启动时仍然收到以下错误。
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.
注意:我当然已经安装了package pip install cx-Oracle
并且正在正确import cx_Oracle
我试过以下没有运气
将即时客户端提取到/opt/oracle/instantclient_19_8
$ ln -s /opt/oracle/instantclient_19_8/libclntsh.dylib /usr/local/lib/
和
mkdir ~/lib
ln -s /opt/oracle/instantclient_19_8/libclntsh.dylib ~/lib/
有了这些,我确实得到了一个有希望的错误,但是,我不知道接下来要“尝试”什么
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
我确实有一个解决方法,其中涉及添加一个带有指向我下载客户端的链接的 init,正如您所想象的那样,这并不理想,因为您必须根据需要为每个 repo 进出,并且永远不会想要时机成熟时将此提交给 git。
import cx_Oracle
cx_Oracle.init_oracle_client(lib_dir=f'/xxx/xxx/xxx/instantclient_19_8')
macOS 限制了库的使用,这很痛苦。
macOS 上有两种解决方案:
cx_Oracle.init_oracle_client()
。 我倾向于这样写:if platform.system() == "Darwin":
cx_Oracle.init_oracle_client(lib_dir=os.environ.get("HOME")+"/Downloads/instantclient_19_8")
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/
当 Oracle 发布“瘦” Python 驱动程序时,您将不需要 Instant Client,也不需要执行其中任何一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.