赞
踩
因oracle官方驱动暂无m1-arm版本,所以使用arm的python解释器报驱动错误,只能使用intel版本转译
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "dlopen(libclntsh.dylib, 0x0001): tried: '/Users/xxx/software/oracle/instantclient_19_8/libclntsh.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))), 'libclntsh.dylib' (no such file), '/usr/lib/libclntsh.dylib' (no such file), '/Users/xxx/software/oracle/instantclient_19_8/libclntsh.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))), '/Users/xxx/Project/PyProject/libclntsh.dylib' (no such file)". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
1、安装intel版本的Python3 任选一个安装即可
https://www.python.org/downloads/macos/
2、使用pip安装cx_Oracle
pip3 install cx_Oracle
3、下载oracle驱动
https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html
4、解压到目录并配置环境变量
# 需要将目录替换成自己的
# Oracle的OCI套件
export DYLD_LIBRARY_PATH=/Users/xxxx/software/oracle/instantclient_19_8
export PKG_CONFIG_PATH=/Users/xxxx/software/oracle
# 刷新环境变量 此处不一定都是该文件 根据terminal决定
source /etc/profile
请注意此处使用Python intel解释器运行
import cx_Oracle
tns = '用户名/密码@IP地址:端口/sid'
db1 = cx_Oracle.connect(tns)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。