无法使用Python CX_oracle设置连接到Oracle DB

发布于 2025-01-23 20:41:21 字数 937 浏览 2 评论 0 原文

我正在使用M1 Mac使用python 3中的cx_oracle连接到Oracle DB

import cx_Oracle
import os
import platform

dsn_tns = cx_Oracle.makedsn('host', 'port', service_name='tns_service_name')
conn = cx_Oracle.connect(user='user', password='pwd', dsn=dsn_tns)
cx_Oracle.init_oracle_client(lib_dir='/Users/user/Downloads/instantclient_19_8')

。 -cx-oracle-on-macos“ rel =“ nofollow noreferrer”>在这里并安装了Oracle客户端,但仍无法连接并给我以下错误。

数据库:DPI-1047:无法找到64位Oracle客户端库: “ dlopen(libclntsh.dylib,0x0001):尝试:'libclntsh.dylib'(没有这样 文件),'/usr/lib/libclntsh.dylib'(没有这样的文件), '/users/balikuma/desktop/libclntsh.dylib'(没有这样的文件)。 寻求帮助

I am using M1 Mac to connect to Oracle DB using cx_Oracle in Python 3.

import cx_Oracle
import os
import platform

dsn_tns = cx_Oracle.makedsn('host', 'port', service_name='tns_service_name')
conn = cx_Oracle.connect(user='user', password='pwd', dsn=dsn_tns)
cx_Oracle.init_oracle_client(lib_dir='/Users/user/Downloads/instantclient_19_8')

I have followed the instructions from here and installed the oracle client but still unable to connect and gives me the following error.

DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library:
"dlopen(libclntsh.dylib, 0x0001): tried: 'libclntsh.dylib' (no such
file), '/usr/lib/libclntsh.dylib' (no such file),
'/Users/balikuma/Desktop/libclntsh.dylib' (no such file)". See
https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
for help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感性 2025-01-30 20:41:21

为了避免在Apple M1芯片上的Python中获取错误DPI-1047,您可以升级CX_oracle。最新的主要版本(取代cx_oracle 8.3)具有新名称 python-oraclecledb 。默认情况下,此新版本不需要Oracle客户端库。检查安装文档

还有用于MacOS X86和M1的通用二进制软件包,因此您无需编译驱动程序或使用Rosetta。 MacOS上存在Python 3.8、3.9和3.10的软件包。

To avoid getting the error DPI-1047 in Python on Apple M1 chips, you can upgrade cx_Oracle. The latest major version (which supersedes cx_Oracle 8.3) has a new name python-oracledb. By default this new version doesn't need Oracle Client libraries. Check the installation documentation.

There are also Universal binary packages for macOS x86 and M1 so you don't need to compile the driver or use Rosetta. Packages exist for Python 3.8, 3.9 and 3.10 on macOS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文