windows下Python连接Oracle

本文档介绍了在Windows 10系统下,使用Python 2.7连接Oracle数据库的步骤。首先,由于使用`easy_install`或`pip`安装cx_Oracle会出现错误,建议直接下载cx_Oracle的.exe文件进行安装。接着,需要从Oracle官网下载Instant Client并解压,设置ORACLE_HOME环境变量及将其添加到PATH。最后,通过Python测试连接,无需在本地安装Oracle或创建tnsnames.ora文件。
摘要由CSDN通过智能技术生成

安装出错:

distutils.errors.DistutilsSetupError: cannot locate Oracle include files in

或者运行出错:

cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle

均可参考该文章


环境:

windows10(同样适用于windows7,8),python2.7

1.下载cx_Oracle

在windows下不要使用easy_install或者pip,因为这样安装不会同步环境,并报错:

distutils.errors.DistutilsSetupError: cannot locate Oracle include files in...

因此下载.exe文件安装

https://pypi.python.org/pypi/cx_Oracle 下载cx_Oracle-5.2.1-12c.win-amd64-py2.7.exe (md5)


2.下载Oracle Instant Client

去http://www.oracle.com/technetwork/topics/winx64soft-089540.html下载 instantclient-basic-windows.x64-12.1.0.2.0.zip 

下载后解压到某一路径,并将该路径添加到系统的环境变量,命名为ORACLE_HOME,将ORACLE_HOME添加到path下,否则会报错

cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值