MENU

Failed to execute script 'pyiboot01_bootstrap' due to unhandled exception

January 10, 2023 • 阅读: 1500 • 笔记&折腾

错误码:[3596] Failed to execute script 'pyiboot01_bootstrap' due to unhandled exception!

现象

在 windows 10 机器上使用 pyinstaller 将 .py 程序打包成 .exe 文件,在其他 windows 10 机器上运行正常,在部分 windows 7 机器上运行时发生以下错误:

Traceback (most recent call last):
  File "PyInstaller\loader\pyiboot01_bootstrap.py", line 111, in <module>
  File "PyInstaller\loader\pyimod04_pywin32.py", line 38, in install
  File "os.py", line 1109, in add_dll_directory
OSError: [WinError 127] 找不到指定的程序。: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\_MEI35842\\pywin32_system32'
[3596] Failed to execute script 'pyiboot01_bootstrap' due to unhandled exception!

exe 文件构建时的环境为:

  • 操作系统:Windows 10;
  • python 版本:3.8.2
  • pyinstaller 版本:5.6.1

原因

在社区中翻了一些类似的问题:

#4213: Program fails at pyiboot01_bootstrap when using --noconsole
#4706: Failed to execute script pyi_rth_multiprocessing, ImportError on elder win7x86

发现问题很有可能出在 Windows 7 操作系统的补丁或者 python 版本上。因为自从 Windows 7 升级到 sp1 之后,想要使用 python 3.7+ 版本,就必须安装补丁 KB2533623 ,否则就只能使用 python 3.6 及以下版本。

解决方案

1)给需要运行该 exe 程序的 Windows 7 机器安装补丁 KB2533623

2)修改生成 exe 程序的环境,将 python 运行环境修改为 3.6。

试了第二种方法,将 python 的运行环境修改为 python 3.6.8,并将 pyinstaller 库版本修改为 4.10。然后再进行编译,生成的 exe 程序在 Windows 7 环境上运行已经不会再出现该错误。

Leave a Comment

2 Comments
  1. 很好的文章

  2. 路人 路人