Python插件cx_Oracle的安装

来源:互联网 发布:表白二维码生成器软件 编辑:程序博客网 时间:2024/06/05 19:22

只需两步。

1.去下载个正确版本的exe文件并安装

点击这里

并不需要如下做法

C:\Users\Tian\AppData\Local\Programs\Python\Python35\Scripts>pip install cx_OracleCollecting cx_Oracle  Using cached cx_Oracle-5.3.tar.gz    Complete output from command python setup.py egg_info:    Traceback (most recent call last):      File "<string>", line 1, in <module>      File "C:\Users\Tian\AppData\Local\Temp\pip-build-axe3mvs8\cx-Oracle\setup.py", line 190, in <module>        raise DistutilsSetupError(message)    distutils.errors.DistutilsSetupError: cannot locate Oracle include files in D:\oracle\instantclient_11_2\    ----------------------------------------Command "python setup.py egg_info" failed with error code 1 in C:\Users\Tian\AppData\Local\Temp\pip-build-axe3mvs8\cx-Oracle\


2.安装instant_client

点击这里,下载正确的版本。


把本文件夹中所有的dll文件复制到python的site-packages文件夹下

可以解决如下问题:

>>> db = cx_Oracle.connect('test', 'test', '40.1.10.15:1521/tian')Traceback (most recent call last):  File "<pyshell#5>", line 1, in <module>    db = cx_Oracle.connect('test', 'test', '40.1.10.15:1521/tian')cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle



3.如下问题的原因是oci.dll版本不对所导致的,请回到第二步重新下载正确版本的instant_client

>>> import cx_OracleTraceback (most recent call last):  File "<pyshell#0>", line 1, in <module>    import cx_OracleImportError: DLL load failed: %1 不是有效的 Win32 应用程序。





参考文档:

http://blog.csdn.net/u013600225/article/details/51168607

http://frenchmay.iteye.com/blog/1060631

0 0
原创粉丝点击