在 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 版本。
相关推荐
树獭非懒10 小时前
AI大模型小白手册|Embedding 与向量数据库
后端·python·llm
唐叔在学习13 小时前
就算没有服务器,我照样能够同步数据
后端·python·程序员
曲幽15 小时前
FastAPI流式输出实战与避坑指南:让AI像人一样“边想边说”
python·ai·fastapi·web·stream·chat·async·generator·ollama
Flittly15 小时前
【从零手写 AI Agent:learn-claude-code 项目实战笔记】(1)The Agent Loop (智能体循环)
python·agent
vivo互联网技术16 小时前
ICLR2026 | 视频虚化新突破!Any-to-Bokeh 一键生成电影感连贯效果
人工智能·python·深度学习
敏编程17 小时前
一天一个Python库:virtualenv - 隔离你的Python环境,保持项目整洁
python
喝茶与编码20 小时前
Python异步并发控制:asyncio.gather 与 Semaphore 协同设计解析
后端·python
zone773920 小时前
003:RAG 入门-LangChain 读取图片数据
后端·python·面试
用户83562907805120 小时前
在 PowerPoint 中用 Python 添加和定制形状的完整教程
后端·python