程序工作正常,包括 win32gui 调用,但可执行文件给出此错误
File "Client.py", line 1, in <module>
ImportError: DLL load failed while importing win32gui: Le module spécifié est introuvable.
[4628] Failed to execute script Client```
I am running on :
Win 10
Python 3.8
最佳答案
问题是隐藏导入
因此,如果有人遇到同样的问题,您需要在构建可执行文件时添加缺少的模块,如下所示:
pyinstaller pathToYourPythonFile/script.py --onefile --hidden-import theMissingModule
就我而言,缺少的模块是win32gui。修复后,又是一个:来自 d3dshot 的 screenshot_every 图书馆
所以基本上,如果它是一个子导入,你会遇到这个问题:
从 d3dshot 导入 snapshot_every
所以 snapshot_every 是隐藏导入(您需要执行此操作来减少.exe大小)
关于python - Pyinstaller导入错误: DLL load failed while importing win32gui,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61130284/