畢業(yè)設(shè)計(jì)做網(wǎng)站答辯深圳剛剛突然宣布
在 MacOS M系列處理器上使用 Anaconda 開(kāi)發(fā) Oralce 的Python程序
因oracle官方驅(qū)動(dòng)暫無(wú) 蘋(píng)果 M 系列處理器版本,所以使用Arm的python解釋器報(bào)驅(qū)動(dòng)錯(cuò)誤:
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版本轉(zhuǎn)譯。
如果使用 Anaconda 來(lái)管理包的話,可以這樣安裝。
一、到Oracle的官網(wǎng)上下載對(duì)應(yīng)版本的驅(qū)動(dòng),下載 basic 的即可。
https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html
二、將驅(qū)動(dòng)解壓,并放到合適的位置,例如:放在
/Users/oneuser/apptools/oracle/instantclient_11_2
并修改 ~.zsh (這里要適配你所用的Shell,有可能是~.bashrc),增中一個(gè)導(dǎo)出
export DYLD_LIBRARY_PATH=/Users/oneuser/apptools/instantclient_11_2/%
保存
三、用Anaconda創(chuàng)建一個(gè)環(huán)境,打開(kāi)一個(gè)新的終端,輸入
CONDA_SUBDIR=osx-64 conda create -n pyoraintel python=3.9conda activate pyoraintelpip3 install cx_oracle #一定要用 pip3 來(lái)安裝,不要用 conda 來(lái)安裝,用conda來(lái)安裝會(huì)錯(cuò)安裝成 arm 版本。