【问题标题】:Pyinstaller ImportError : DLL load failed while importing win32guiPyinstaller ImportError:导入 win32gui 时 DLL 加载失败
【发布时间】:2020-04-09 21:12:57
【问题描述】:

程序运行良好,包括 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

【问题讨论】:

    标签: python dll pyinstaller pywin32 win32gui


    【解决方案1】:

    问题是隐藏的导入

    所以如果有人有同样的问题,你需要在构建可执行文件时添加缺少的模块,如下所示:

    pyinstaller pathToYourPythonFile/script.py --onefile --hidden-import theMissingModule
    

    就我而言,缺少的模块是 win32gui。修复后,又是一个:screenshot_every from d3dshot library

    所以基本上你会遇到这个问题,如果它是一个 sub import aka :

    from d3dshot import screenshot_every

    所以 screenshot_every 是隐藏导入(您需要这样做以减少 .exe 大小)

    【讨论】:

    • 我试过pyinstaller pathToYourPythonFile/script.py --onefile --hidden-import win32gui,但错误仍然存​​在。您能否详细说明您如何解决win32gui 的问题?
    • @KlienMenard 发布一个包含详细信息的问题,以便我们为您提供帮助
    【解决方案2】:

    Win32gui 与python-3.7 或更高版本不兼容

    python-3.7 于 2018 年发布,win32gui 的最新版本于 2017 年 8 月发布。

    安装pywin32。这给了你win32gui

    $pip install pywin32
    import win32api
    

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 2021-07-25
      • 2021-04-17
      • 1970-01-01
      • 2012-02-02
      • 1970-01-01
      • 2022-10-12
      • 2021-05-21
      • 2019-06-12
      相关资源
      最近更新 更多