python - 使用 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")
我是如何打包的:
- 转到您要将应用程序打包到的某个文件夹。我称它为部长。
- 确保它是空的。
- python -m PyInstaller --name 应用程序 C:\path\to\application.py
- python -m PyInstaller application.spec
- 该 exe 位于 ministaller\dist\application 文件夹中。通过 cmd 调用它以查看错误消息。
解决方案
我在 PyInstaller GitHub 上发布了这个问题,那里给出的答案为我解决了这个问题: https ://github.com/pyinstaller/pyinstaller/issues/5572
推荐阅读
- ios - 按下按钮 ios 时应用程序崩溃
- java - 基于带注释的方法值类型定义通用 Protobuf 转换器
- sitecore - 我无法通过 GatherContent 模块将数据迁移到 Sitecore/Content Field 项目
- json - Python字典将单斜杠转换为双斜杠
- android - 当我安装新的 apk 时,出现此错误:“Java.Lang.NullPointerException:尝试调用虚拟方法.....”
- bash - 如何在 Matlab m 文件中使用 Bash shell 脚本中的变量
- c++ - 使用 nvcc (CUDA-RINSIDE) 正确链接对象文件
- r - 时间序列中多列当前总和的基于行的计算
- selenium - 在 Firefox 中使用 Nightwatch 运行测试无法连接到 Selenium 服务器
- java - GraphQL Java 类生成器