无法使用Python CX_oracle设置连接到Oracle DB
我正在使用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'(没有这样的文件)。 寻求帮助
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了避免在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.