OSX上安装cx_Oracle

OSX 上安装cx_Oracle

一、下载cx_Oracle 安装包和Oracle Instant Client + SDK

1、cx_Oracle — Source Code Only Option — (http://cx-oracle.sourceforge.net/)
2、Oracle Instant Client Basic 64-bit (http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)
3、Oracle Instant Client SDK 64-bit (http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)

二、安装

1、安装环境准备

sudo su
mkdir /Users/Terry/oracle
mv /Users/Terry/Downloads/instantclient-* /Users/Terry/oracle
cd /Users/Terry/oracle
unzip instantclient-basic-macos.x64-11.2.0.3.0.zip
unzip instantclient-sdk-macos.x64-11.2.0.3.0.zip
cd instantclient_11_2/sdk
unzip ottclasses.zip
cd ..
cp -R ./sdk/* .
cp -R ./sdk/include/* .
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
vim ~/.bash_profile

.bash_profile中增加如下内容

export ORACLE_HOME=/Users/Terry/oracle/instantclient_11_2
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME

同时在你的用户的.bash_profile增加同样的内容

2、验证下安装环境是否正确

. ~/.bash_profile
echo $ORACLE_HOME
echo $DYLD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
which python
which gcc

3、安装

. ~/.bash_profile
cd /Users/username_here/Downloads
tar -xzf cx_Oracle-5.1.2.tar.gz
cd cx_Oracle-5.1.2
sudo -E python setup.py build
sudo -E python setup.py install

$ sudo mkdir -p /ade/b/3071542110/oracle/rdbms/lib/
$ sudo mkdir -p /ade/dosulliv_ldapmac/oracle/ldap/lib/
$ cd /ade/b/3071542110/oracle/rdbms/lib/
$ sudo ln -s /Users/Terry/oracle/instantclient_11_2/libclntsh.dylib.11.1 libclntsh.dylib.11.1
$ cd /ade/dosulliv_ldapmac/oracle/ldap/lib/
$ sudo ln -s /Users/Terry/oracle/instantclient_11_2/libnnz11.dylib libnnz11.dylib

4、验证

python
import cx_Oracle

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>