解决linux精简客户端下安装python的oracle模块出现的错误

安装cx_Oracle-5.1.3时:

执行$ python setup.py build

能正确构建,但安装时出现以下问题:

sudo python setup.py install

Traceback (most recent call last):

  File "setup.py", line 135, in

    raiseDistutilsSetupError("cannot locate an Oracle software " \

distutils.errors.DistutilsSetupError: cannot locate an Oraclesoftware installation

原因分析:

sudo env | grep ORACLE_HOME没有输出,说明root用户的oracle环境没有配置,故出现以上错误

参考:

http://lorcancoyle.org/wiki/public/cxoracle

解决办法:

su -

vi /root/.bashrc

追加以下内容:

#oracle 11g installclient env

export ORACLE_HOME=/opt/ora11g/instantclient_11_2

export TNS_ADMIN=$ORACLE_HOME/network/admin

export NLS_LANG='simplified chinese_china'.UTF8

export PATH=$PATH:$ORACLE_HOME/bin


source /root/.bashrc

进入cx_Oracle-5.1.3源代码路径,执行python setup.py install

安装成功

登出root


$ python

Python 2.7.6 (default, Mar 22 2014,22:59:56) 

[GCC 4.8.2] on linux2

Type "help", "copyright", "credits" or "license" for moreinformation.

>>> import cx_Oracle

>>> conn =cx_Oracle.connect('scott/tiger@orcl')

>>> quit()


你可能感兴趣的:(解决linux精简客户端下安装python的oracle模块出现的错误)