简体   繁体   English

在 Mac 上使用 Python 连接到 Oracle 时出错 - 找不到 Oracle 客户端库

[英]Getting Error Connect to Oracle using Python On Mac - Cannot locate Oracle Client library

I'm trying to connect to Oracle database in Python on Mac but getting the following error:我正在尝试在 Mac 上连接到 Python 中的 Oracle 数据库,但出现以下错误:

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 1): image not found". cx_Oracle.DatabaseError:DPI-1047:找不到 64 位 Oracle 客户端库:“dlopen(libclntsh.dylib, 1): image not found”。 See https://oracle.github.io/odpi/doc/installation.html#macos for help请参阅https://oracle.github.io/odpi/doc/installation.html#macos寻求帮助

The code causing the error is dsn_tns = cx_Oracle.makedsn(host='', port='', service_name='') conn = cx_Oracle.connect(user='', password='', dsn=dsn_tns)导致错误的代码是 dsn_tns = cx_Oracle.makedsn(host='', port='', service_name='') conn = cx_Oracle.connect(user='', password='', dsn=dsn_tns)

Using the cx_Oracle Library使用 cx_Oracle 库

This is my lib folder这是我的 lib 文件夹

$ ls -la ~/lib $ ls -la ~/lib

total 274272总计 274272

drwxr-xr-x 7 staff 224 Jun 25 13:31. drwxr-xr-x 7 名员工 224 Jun 25 13:31。

drwxr-xr-x+ 113 staff 3616 Jun 25 14:20.. drwxr-xr-x+ 113 员工 3616 Jun 25 14:20..

lrwxr-xr-x 1 staff 61 Jun 24 18:03 libclntsh.dylib -> /Users/username/oracle/instantclient_19_3/libclntsh.dylib lrwxr-xr-x 1 名员工 61 Jun 24 18:03 libclntsh.dylib -> /Users/username/oracle/instantclient_19_3/libclntsh.dylib

lrwxr-xr-x 1 staff 51 Jun 25 13:31 libclntsh.dylib.19.1 -> /opt/oracle/instantclient_19_1/libclntsh.dylib.19.1 lrwxr-xr-x 1 名员工 51 Jun 25 13:31 libclntsh.dylib.19.1 -> /opt/oracle/instantclient_19_1/libclntsh.dylib.19.1

-rwxr-xr-x@ 1 staff 4803832 Jun 24 18:31 libclntshcore.dylib.19.1 -rwxr-xr-x@ 1 名员工 4803832 6 月 24 日 18:31 libclntshcore.dylib.19.1

-rwxr-xr-x@ 1 staff 8349944 Jun 24 18:30 libnnz19.dylib -rwxr-xr-x@ 1 名员工 8349944 6 月 24 日 18:30 libnnz19.dylib

-rwxr-xr-x@ 1 staff 125518764 Jun 24 18:31 libociei.dylib -rwxr-xr-x@ 1 名员工 125518764 Jun 24 18:31 libociei.dylib

MacOS: Catalina Version 10.15.5 Python 3.7.7 Oracle client MacOS:Catalina 版本 10.15.5 Python 3.7.7 Oracle 客户端

In cx_Oracle 8 there is a new initialization method that you can call in your scripts to specify the Instant Client directory:在 cx_Oracle 8 中有一个新的初始化方法,您可以在脚本中调用它来指定 Instant Client 目录:

import platform

if platform.platform()[:6] == 'Darwin':
    cx_Oracle.init_oracle_client(lib_dir="/Users/cjones/instantclient_19_3")

You can also add a symlink in the appropriate site-packages directory, but I think init_oracle_client() is easier.您还可以在适当的站点包目录中添加符号链接,但我认为init_oracle_client()更容易。

Check the updated installation instructions and the new initialization documentation .检查更新的安装说明和新的初始化文档

暂无
暂无

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

相关问题 使用Python的Oracle DB连接错误-cx_Oracle:无法找到32位Oracle Client库 - Oracle DB connection error with Python - cx_Oracle: cannot locate a 32-bit Oracle Client library 使用即时客户端通过 Python3 (cx_Oracle) 连接到 Oracle 数据库时出现错误“DPI-1047:无法找到 64 位 Oracle 客户端库” - Error “DPI-1047: Cannot locate a 64-bit Oracle Client library” when connecting to Oracle Database with Python3 (cx_Oracle) using instant client cx-Oracle 找不到 Oracle 客户端库 - cx-Oracle cannot locate Oracle client library cx_Oracle 和 Lambda 层错误 - aws lambda 找不到 64 位 oracle 客户端库 - cx_Oracle and Lambda Layer error - aws lambda cannot locate a 64-bit oracle client library cx_Oracle 错误。 DPI-1047:找不到 64 位 Oracle 客户端库 - cx_Oracle error. DPI-1047: Cannot locate a 64-bit Oracle Client library Linux。 连接到 Oracle。 cx_Oracle.DatabaseError:DPI-1047 找不到 64 位 Oracle 客户端库:“libclntsh.so - Linux. Connect ot Oracle. cx_Oracle.DatabaseError: DPI-1047 Cannot locate a 64-bit Oracle Client library: "libclntsh.so cx_Oracle.DatabaseError: DPI-1047: 无法找到 64 位 Oracle 客户端库 UBUNTU - cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library UBUNTU cx_Oracle 连接失败并显示“DPI-1047:找不到 64 位 Oracle 客户端库” - cx_Oracle connection fails with 'DPI-1047: Cannot locate a 64-bit Oracle Client library' Crontab 错误:找不到 64 位 Oracle 客户端库:“libclntsh.so:无法打开共享 object 文件:没有这样的文件或目录 - Crontab error: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory mac 无法加载 64 位 Oracle 客户端库 - 64-bit Oracle Client library cannot be loaded in mac
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM