首页 > 解决方案 > 使用 Oracle 数据库连接的 Python 应用程序的 PyInstaller 打包问题

问题描述

我正在尝试使用 pyinstaller 打包 python 应用程序。我正在使用 cx_oracle 和 oracle 即时客户端连接到 oracle 数据库。我正在使用 Windows 10。我的应用程序在打包之前运行良好。但是打包后,我尝试运行可执行文件时出现如下错误:

cx_Oracle.DatabaseError:DPI-1072:不支持 Oracle 客户端库版本

此错误发生在行中cx_Oracle.init_oracle_client(lib_dir=r"instantclient_19_9")。根据 ODPI 日志,Oracle Instant Client 加载成功,但在验证时出现错误。问题不是由于系统上的 Oracle Instant Client 版本不同。我检查了系统上的其他版本,但没有。此外,当我删除我尝试加载的 Oracle Instant Client 时,会发生不同的错误,即未找到 Oracle Instant 客户端。当我在模拟或省略数据库连接时打包应用程序时,打包工作正常。

我已经在两个不同的系统上尝试了所有方法,但我遇到了同样的问题。另一个人也可以重现我的问题。此外,我可以使用以下玩具示例复制此错误:

不需要存在 Oracle 数据库。Oracle Instant Client 需要安装到以下文件所在的文件夹中。

import cx_Oracle

if __name__ == "__main__":
    cx_Oracle.init_oracle_client(lib_dir=r"instantclient_19_9")

我是如何打包的:

标签: pythonwindowsoraclepyinstaller

解决方案


我在 PyInstaller GitHub 上发布了这个问题,那里给出的答案为我解决了这个问题: https ://github.com/pyinstaller/pyinstaller/issues/5572


推荐阅读