PySide2 和 pyinstaller gui 应用程序无法在某些 Windows 计算机上运行



我使用 PySide2 作为我的 gui 框架和 PyInstaller 构建了一个小型 gui 应用程序来制作一个文件 exe 文件。

该应用程序在某些 PC(Windows 7 和 10(上运行良好,但是,在其他一些 PC 上它无法启动 - 向我显示错误消息:

"致命错误!:无法执行脚本pyi_rth_qt5plugins">

我相信它可能没有捆绑Qt5Gui.dll,Qt5Core.dll和Qt5Widgets.dll,但是我不知道如何使用PyInstaller执行此操作。

有谁知道如何解决这个问题?

这是我的 .spec 文件:

# -*- mode: python -*-
block_cipher = None
a = Analysis(['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='Application',
debug=True,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True , icon='Images\Application_icon.ico')

编辑

这是从 cmd 和 debug=True 运行时的完整输出。我觉得奇怪的一件事是它指的是我开发应用程序的 PC(例如File "c:usersjakeProjectsApplicationvenvlibsite-packagesPyInsta llerloaderpyimod03_importers.py", line 714, in load_module(,而不是我正在测试并从中收到此错误消息的 PC。

[4588] PyInstaller Bootloader 3.x
[4588] LOADER: executable is C:UsersUserDesktopApplication.exe
[4588] LOADER: homepath is C:UsersUserDesktop
[4588] LOADER: _MEIPASS2 is NULL
[4588] LOADER: archivename is C:UsersUserDesktopApplication.exe
[4588] LOADER: Extracting binaries
[4588] LOADER: Executing self as child
[4588] LOADER: set _MEIPASS2 to C:UsersUserAppDataLocalTemp_MEI45882
[4588] LOADER: Setting up to run child
[4588] LOADER: Creating child process
[4588] LOADER: Waiting for child process to finish...
[4752] PyInstaller Bootloader 3.x
[4752] LOADER: executable is C:UsersUserDesktopApplication.exe
[4752] LOADER: homepath is C:UsersUserDesktop
[4752] LOADER: _MEIPASS2 is C:UsersUserAppDataLocalTemp_MEI45882
[4752] LOADER: archivename is C:UsersUserDesktopApplication.exe
[4752] LOADER: SetDllDirectory(C:UsersUserAppDataLocalTemp_MEI45882)
[4752] LOADER: Already in the child - running user's code.
[4752] LOADER: manifestpath: C:UsersUserAppDataLocalTemp_MEI45882Application.exe.manifest
[4752] LOADER: Activation context created
[4752] LOADER: Activation context activated
[4752] LOADER: Python library: C:UsersUserAppDataLocalTemp_MEI45882py
thon36.dll
[4752] LOADER: Loaded functions from Python library.
[4752] LOADER: Manipulating environment (sys.path, sys.prefix)
[4752] LOADER: Pre-init sys.path is C:UsersUserAppDataLocalTemp_MEI458
82base_library.zip;C:UsersUserAppDataLocalTemp_MEI45882
[4752] LOADER: sys.prefix is C:UsersUserAppDataLocalTemp_MEI45882
[4752] LOADER: Setting runtime options
[4752] LOADER: Bootloader option: pyi-windows-manifest-filename Folder Hatcher.e
xe.manifest
[4752] LOADER: Initializing python
[4752] LOADER: Overriding Python's sys.path
[4752] LOADER: Post-init sys.path is C:UsersUserAppDataLocalTemp_MEI45
882base_library.zip;C:UsersUserAppDataLocalTemp_MEI45882
[4752] LOADER: Setting sys.argv
[4752] LOADER: setting sys._MEIPASS
[4752] LOADER: importing modules from CArchive
[4752] LOADER: extracted struct
[4752] LOADER: callfunction returned...
[4752] LOADER: extracted pyimod01_os_path
[4752] LOADER: callfunction returned...
[4752] LOADER: extracted pyimod02_archive
[4752] LOADER: callfunction returned...
[4752] LOADER: extracted pyimod03_importers
[4752] LOADER: callfunction returned...
[4752] LOADER: Installing PYZ archive with Python modules.
[4752] LOADER: PYZ archive: PYZ-00.pyz
[4752] LOADER: Running pyiboot01_bootstrap.py
[4752] LOADER: Running pyi_rth_qt5plugins.py
Traceback (most recent call last):
File "site-packagesPyInstallerloaderrthookspyi_rth_qt5plugins.py", line 47
, in <module>
ModuleNotFoundError: No module named 'PyQt5'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:usersjakeProjectsApplicationvenvlibsite-packagesPyInsta
llerloaderpyimod03_importers.py", line 712, in load_module
File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrappe
r
File "<frozen importlib._bootstrap_external>", line 823, in load_module
File "<frozen importlib._bootstrap_external>", line 682, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "site-packagesPyInstallerloaderrthookspyi_rth_qt5plugins.py", line 49
, in <module>
File "c:usersjakeProjectsApplicationvenvlibsite-packagesPyInsta
llerloaderpyimod03_importers.py", line 714, in load_module
ImportError: DLL load failed: The specified module could not be found.: PySide2.
QtCore
[4752] Failed to execute script pyi_rth_qt5plugins
[4752] LOADER: OK.
[4752] LOADER: Cleaning up Python interpreter.
[4588] LOADER: Back to parent (RC: -1)
[4588] LOADER: Doing cleanup
[4588] LOADER: Freeing archive status for C:UsersUserDesktopApplication.exe

我在使用以下软件包构建 PySide2 应用程序构建时遇到了同样的问题(应用程序在某些但不是所有 Win 客户端上运行良好(:

  • pyinstaller==3.14
  • PySide2==5.12.2
Traceback (most recent call last):
File "site-packagesPyInstallerloaderrthookspyi_rth_qt5plugins.py", line 47, in <module>
ImportError: DLL load failed:

此问题已通过安装 Visual C++2015 重新分发包 (x86( 在 Windows 10 客户端上解决(在某些客户端上(:https://www.microsoft.com/en-us/download/details.aspx?id=53840

然而,我认为这个问题仍在进行中......

我记得在 http://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-data-files 之前使用它

也许它会让你解决。

无论如何,我不是Windows专家,但是使用linux构建创建的二进制文件仅适用于具有与构建相同的发行版和体系结构的盒子/机器

相关内容

最新更新