Install Oracle (cx_Oracle) module for Python

本文详细介绍了如何安装Python的Oracle数据库连接模块cx_Oracle 5.0版本,包括所需软件下载、配置环境变量及具体安装步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cx_Oracle 5.0
Oracle Database connector module for Python

I came across several (CodingNaked WebSite Pedro Emanuel de Castro Faria Blog ) howTo's on the internet explaining how to compile and install previous versions of this connector. I decided to write my own howTo describing the latest version of the module (as of writing cx_Oracle 5.0).

(I am assuming you have the Xcode developers tools already installed since you will need the GCC compiler)

You need the follwing software:

Oracle Instant Client
cx_Oracle Module 5.0

Download the following packages from the Oracle Instant client site:

Instant Client Package - Basic
Instant Client Package - SQL*Plus
Instant Client Package - SDK

Extact all of these, then place their contents into a single directory

In my case I created a director called /opt/oracle/instantclient_10_2, and place all of the contents from all three archives in this directory.

Then run the following commands (assuming you created the same directory)

cd /opt/oracle/instantclient_10_2
ln -s libclntsh.dylib. 10.1 libclntsh.dylib

Now you need to edit you profile:

sudo nano -w /etc/profile

Copy and paste the below (Please note the paths and adjust accordingly)

ORACLE_HOME= "/opt/oracle"
export ORACLE_HOME
 
DYLD_LIBRARY_PATH= "$ORACLE_HOME/instantclient_10_2"
export DYLD_LIBRARY_PATH
 
SQLPATH= "$ORACLE_HOME/instantclient_10_2"
export SQLPATH
 
export PATH= "$PATH:$ORACLE_HOME/instantclient_10_2"

now run the following commands (you need to do this or the build will fail).

cd /opt/oracle/
ln -s libclntsh.dylib. 10.1 libclntsh.dylib

I extracted the cx_Oracle module to /opt/oracle/cx_Oracle-5.0. All you have to do now is run these commands at the module will be built and installed.

cd /opt/oracle/cx_Oracle- 5.0
sudo python setup.py build
sudo python setup.py install

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值