http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html---下载instantclient-basic-linux.x64-11.2.0.4.0
http://sourceforge.net/projects/cx-oracle/files/5.1.2/----下载cx_Oracle-5.1.2.tar.gz
https://pypi.python.org/pypi/cx_Oracle----下载cx_Oracle-5.1.2.tar.gz
linux版本号		CentOS release 6.5 (Final)
python版本号	2.6.6
oracle版本号		11.2.0.4 x86_64

1、安装oracle客户端和sdk
# unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
# cp ~/instantclient_11_2/* /usr/local/oracle_instantclient_11.2.0.4_x86_64/<pre name="code" class="cpp">http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html---下载instantclient-basic-linux.x64-11.2.0.4.0
http://sourceforge.net/projects/cx-oracle/files/5.1.2/----下载cx_Oracle-5.1.2.tar.gz
https://pypi.python.org/pypi/cx_Oracle----下载cx_Oracle-5.1.2.tar.gz
linux版本号		CentOS release 6.5 (Final)
python版本号	2.6.6
oracle版本号		11.2.0.4 x86_64

1、安装oracle客户端和sdk
# unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
# cp ~/instantclient_11_2/* /usr/local/oracle_instantclient_11.2.0.4_x86_64/

# unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip -d /usr/local/oracle_instantclient_11.2.0.4_x86_64/
# cp -rf include/* /usr/local/oracle_instantclient_11.2.0.4_x86_64/

2、环境变量设置
# vi /etc/profile
export ORACLE_HOME=/usr/local/oracle_instantclient_11.2.0.4_x86_64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME:/lib:/usr/lib

# source /etc/profile

3、安装cx_oracle
# tar xvf cx_Oracle-5.1.2.tar.gz 
# ln -sv /usr/local/oracle_instantclient_11.2.0.4_x86_64/libclntsh.so.11.1 /usr/local/oracle_instantclient_11.2.0.4_x86_64/libclntsh.so
# python setup.py build
# python setup.py install
Installed /usr/lib64/python2.6/site-packages/cx_Oracle-5.1.2-py2.6-linux-x86_64.egg
Processing dependencies for cx-Oracle==5.1.2
Finished processing dependencies for cx-Oracle==5.1.2

4、成功安装后进行验证
>>> import cx_Oracle




问题
1、 raise DistutilsSetupError("cannot locate an Oracle software " \
解决:须要设置oracle的环境变量LD_LIBRARY_PATH

2、cx_Oracle.c:10:17: 错误:oci.h:没有那个文件或文件夹
解决:安装oracle jdk

3、/usr/bin/ld: cannot find -lclntsh
解决:创建软链接
ln -sv /usr/local/oracle_instantclient_11.2.0.4_x86_64/libclntsh.so.11.1 /usr/local/oracle_instantclient_11.2.0.4_x86_64/libclntsh.so

4、cx_Oracle.DatabaseError: ORA-00972: identifier is too long和打印的中文字段名为???

?

# export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" ##攻克了一部分问题 # export NLS_LANG="SIMPLIFIED CHINESE_CHINA.UTF8" ##全然攻克了问题