在 MacOS M系列处理器上使用 Anaconda 开发 Oralce 的Python程序

在 MacOS M系列处理器上使用 Anaconda 开发 Oralce 的Python程序

因oracle官方驱动暂无 苹果 M 系列处理器版本,所以使用Arm的python解释器报驱动错误:

bash 复制代码
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

因此,只能使用intel版本转译。

如果使用 Anaconda 来管理包的话,可以这样安装。

一、到Oracle的官网上下载对应版本的驱动,下载 basic 的即可。

html 复制代码
https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

二、将驱动解压,并放到合适的位置,例如:放在

html 复制代码
/Users/oneuser/apptools/oracle/instantclient_11_2

并修改 ~.zsh (这里要适配你所用的Shell,有可能是~.bashrc),增中一个导出

bash 复制代码
export DYLD_LIBRARY_PATH=/Users/oneuser/apptools/instantclient_11_2/%

保存

三、用Anaconda创建一个环境,打开一个新的终端,输入

bash 复制代码
CONDA_SUBDIR=osx-64 conda create -n pyoraintel python=3.9

conda activate pyoraintel

pip3 install cx_oracle  #一定要用 pip3 来安装,不要用 conda 来安装,用conda来安装会错安装成 arm 版本。
相关推荐
数据智能老司机13 小时前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
数据智能老司机14 小时前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i15 小时前
django中的FBV 和 CBV
python·django
c8i15 小时前
python中的闭包和装饰器
python
这里有鱼汤19 小时前
小白必看:QMT里的miniQMT入门教程
后端·python
TF男孩1 天前
ARQ:一款低成本的消息队列,实现每秒万级吞吐
后端·python·消息队列
该用户已不存在1 天前
Mojo vs Python vs Rust: 2025年搞AI,该学哪个?
后端·python·rust
站大爷IP1 天前
Java调用Python的5种实用方案:从简单到进阶的全场景解析
python
小溪彼岸2 天前
macOS自带截图命令ScreenCapture
macos
用户8356290780512 天前
从手动编辑到代码生成:Python 助你高效创建 Word 文档
后端·python