1、安装cx_Oracle
1)下载cx_Oracle,https://pypi.python.org/pypi
2)解压压缩包
3)执行python setup.py install
执行后报错:error: command ‘gcc‘ failed with exit status 1
排查:
1)检查是否安装oracle客户端软件
2)查看当前环境变量中是否配置oracle的相关变量,如echo $ORACLE_HOME
3)如果没有配置需要将oracle环境变量配置到当前用户.bash_profile中,或/etc/profile中
# cat .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORA_CRS_HOME=$ORACLE_BASE/product/10.2.0/crs_1
export ORACLE_SID=icpdb
export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/JRE
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export THREADS_FLAG=native
export DISPLAY=192.168.196.5:0.0
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
安装cx_Oracle时报错:error: command 'gcc' failed with exit status 1