Skip to content

Instantly share code, notes, and snippets.

@TheWaWaR
Created June 14, 2013 02:03
Show Gist options
  • Save TheWaWaR/5778944 to your computer and use it in GitHub Desktop.
Save TheWaWaR/5778944 to your computer and use it in GitHub Desktop.
在 CentOS 上安装 cx_Oracle
# 从 Oracle 官方网站下载下列文件:
#
# oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
# oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
# oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm
# 安装 Oracle 客户端
rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
#:::: [可选] sqlplus 不是必须的,但可以方便测试 Oracle
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm
# 导入环境变量
export LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib:${LD_LIBRARY_PATH}"
export ORACLE_HOME="/usr/lib/oracle/11.2/client64/lib"
# 建立到 ORACLE_HOME 的符号链接, 避免出现 "cannot locate Oracle include files" 错误
mkdir /usr/lib/oracle/11.2/client64/lib/sdk
ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/lib/sdk/include
# 开始安装 cx_Oracle
cd /path/to/cx_Oracle.xx.xx # 进入 cx_Oracle 安装包的目录
python setup.py build
python setup.py install
# 临时测试是否安装成功
python -c "import cx_Oracle"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment