linux环境下cx_Oracle的“ImportError: No module named cx_Oracle”错误。
环境:redhat AS + python2.7 + oracle instant client + cx_oracle
oracle instant client10.2.4 (linux)
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
我下载的是:oracle-instantclient-basic-10.2.0.4-1.i386.rpm 和oracle-instantclient-devel-10.2.0.4-1.i386.rpm
python2.7
http://cx-oracle.sourceforge.net/
我下载的源码包是:cx_Oracle-5.0.4.tar.gz
环境变量:
export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
遇到的问题:
在软件安装完毕,环境变量配置成功后,报错:“ImportError: No module named cx_Oracle”
解决:cx oracle官方下载源码包,编译后在安装,搞定了。
http://cx-oracle.sourceforge.net/,找到对应版本的“Source Code only”,下载后按照redme指示,
python setup.py build
python setup.py install
再次python import cx_Oracle,不报错了