操作系统:mac os 10.11
python 版本:2.7.11
0 下载 oracle Instant Client (下载地址:http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html) 中的basic 和sdk
1安装
创建文件/opt
复制文件到/opt sudo cp -r instantclient_12_1 /opt/
复制sdk sudo cp sdk /opt/instantclient_12_1/
2 配置.bash_profile
vim ~/.bash_profile
#Setting PATH for Oracle
DYLD_LIBRARY_PATH=/opt/instantclient_12_1
export DYLD_LIBRARY_PATH
export ORACLE_HOME=$DYLD_LIBRARY_PATH
export PATH=$ORACLE_HOME:$PATH
export VERSIONER_PYTHON_PREFER_32_BIT=Yes
3设置软链
ln -s libclntsh.so.12.1 libclntsh.so
sudo ln -s libclntsh.dylib.12.1 libclntsh.dylib
sudo ln -s libocci.dylib.12.1 libocci.dylib
4安装cx_Oracle
pip install cx_Oracle
完成!