1. 下载 oracle instantclient-basic
http://download.oracle.com/otn/linux/instantclient/112020/instantclient-basic-linux-x86-64-11.2.0.2.0.zip
2. 安装配置oracle instant client
unzip instantclient-basic-linux-x86-64-11.2.0.2.0.zip
cp -rf instantclient_11_2 /opt/
vi /root/.bash_profile
export ORACLE_HOME=/opt/instantclient_11_2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
source /root/.bash_profile
如果机器上本来就有oracle,已经存在<span style="font-family: Arial, Helvetica, sans-serif;">$ORACLE_HOME/instantclient </span>,那么只需要将<span style="font-family: Arial, Helvetica, sans-serif;">instantclient_11_2中的内容,拷贝到现有的instantclient目录。</span>
<span style="font-family: Arial, Helvetica, sans-serif;"> 但是要记得更新</span><span style="font-family: Arial, Helvetica, sans-serif;">LD_LIBRARY_PATH</span>
==>比如: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/instantclient
<pre name="code" class="html"><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px;"><span style="font-size: 10px;"> cd $ORACLE_HOME</span></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; font-family: Arial; line-height: 26px;"><span style="font-size:10px;"> ln -s libclntsh.so.11.1 libclntsh.so</span></p>
3. download and install cx_Oracle-5.1.2.tar.gz
从<a target=_blank href="http://cx-oracle.sourceforge.net/" rel="nofollow" style="color: rgb(53, 114, 176); font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; white-space: nowrap;">http://cx-oracle.sourceforge.net/</a>下载
tar xzvf cx_Oracle-5.1.2.tar.gz
python setup.py build
python setup.py install
4. 验证
$python
>>import cx_Oracle