Python安装cx_Oracle模块遇到的问题

环境:

win7 32位系统

Python3.6 (32bit)

问题

在IDLE中运行

<pre style="overflow: auto; margin-top: 0px; margin-bottom: 0px; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">1 import cx_Oracle</pre>

报错:ImportError: DLL load failed:找不到指定的模块

出现此问题的原因一般是:没有copy 之前提到的oci.dll文件或者是Oracle客户端版本与cx_Oracle版本不一致

而我已经copy了oci.dll文件。而且就文件名称判断来二者版本是一致的

我测试了所有12版本的Oracle客户端,包括64位,均没有成功。(测试64位的时候报错:ImportError: DLL load failed: %1 不是有效的 Win32 应用程序,意思是操作系统、cx_Oracle和instantclient的位数不同,当时实在是想不到别的办法,就各种尝试)

后来意识到或许是cx_Oracle的问题。。。

解决办法

在cmd中运行

<pre style="overflow: auto; margin-top: 0px; margin-bottom: 0px; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">pip install -U cx_Oracle</pre>

更新cx_Oracle模块到最新版本,问题解决。

posted on 2026-09-11 13:39  AI老炮  阅读(5)  评论(0)    收藏  举报