python - Python 的 Oracle DB 连接错误 - cx_Oracle : cx_Oracle. DatabaseError: DPI-1047

标签 python cx-oracle

我正在尝试使用 cx_Oracle(64 位 python)访问我的 Oracle 数据库。我按照指示here进行操作。

我安装了cx_Oracle 7.2.3并下载instantclient-basic-windows.x64-19.3.0.0.0dbru.zipVC 2015-2019 (使用页面中提供的链接)

其实我已经安装了几乎所有版本的VC++

我将 Oracle Instant Client 文件夹添加到我的系统环境变量中,并通过在 cmd 中键入“PATH”来仔细检查它。

但是,当我运行 cx_Oracle.connect('xxx') 时,我仍然收到错误消息,

cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help

导致错误的可能原因是什么?如何修复它?

最佳答案

此错误主要是因为instantclient版本与cx_Oracle不兼容。解决方案是将 InstantClient 替换为错误消息中提到的所需版本(在您的情况下为 64 位)。

如何替换即时客户端: 然后,如果您的问题仍然存在,请在 Oracle Downloads 上找到最新的 instantClient(注意!您的错误指的版本不是您的 Python/Windows 版本,在上述情况下为 64 位) ,下载并将其替换为系统变量中当前的 PATH,或者仅将新下载的内容替换为当前的 instantClient 文件夹。

此外,检查与您的 Oracle DB 版本相对应的 VS 可再发行版本是否正确,并按照 cx_oracle Docs 中的引用进行安装。是建议的方法,但在我们的许多情况下,它并没有引起问题。

关于python - Python 的 Oracle DB 连接错误 - cx_Oracle : cx_Oracle. DatabaseError: DPI-1047,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58252667/

相关文章:

Python + CGI脚本无法访问环境变量

python - 按键时的 Sprite 动画

python - 如何在通话期间通过 GSM 调制解调器发送和接收一些数据(Python 和 AT 命令)

python-3.x - 用于 Python 3.6 的 cx_Oracle

python - 如何从 Python 脚本中创建存储过程?

python - 如何让 cx-oracle 将查询结果绑定(bind)到字典而不是元组?

python - 从 python 脚本使用游标输出参数调用 oracle 存储过程

python - 时间序列数据的异常值检测

python - 我收到 a += b 的 TypeError,但不是 b += a (numpy)

python - 如何从左侧实现对象与 Numpy 数组的乘法?