【问题标题】:PyInstaller ImportError: DLL load failedPyInstaller ImportError:DLL 加载失败
【发布时间】:2017-07-24 16:57:17
【问题描述】:

我对 Python 还是很陌生。我正在使用:

  • Windows 10、64 位
  • Python 3.5.3
  • PyInstaller 3.2.1

我尝试使用 PyInstaller 打包我的第一个 GUI 测试应用程序。我用过

pyinstaller --onedir testgui.py

为此。生成的应用程序没有运行。当我尝试通过命令提示符运行.exe 文件时,它返回了以下消息:

C:\PythonProjects\firstGUI\dist\testgui>testgui.exe
Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_qt5plugins.py", line 46, in <module>
  File "c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 573, in load_module
    module = loader.load_module(fullname)
ImportError: DLL load failed: [Module not found in german....] .
Failed to execute script pyi_rth_qt5plugins

这些是我在非常短的脚本中所做的所有导入:

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

我做错了什么?如果有帮助,我可以发布我在打包过程中收到的所有警告行。

编辑:

在打包过程中,我在日志中收到了一些 WARNING: lib not found 条目。这是完整的打包日志:

C:\PythonProjects\firstGUI>pyinstaller --onedir testgui.py
91 INFO: PyInstaller: 3.2.1
91 INFO: Python: 3.5.3
91 INFO: Platform: Windows-10-10.0.14393-SP0
92 INFO: wrote C:\PythonProjects\firstGUI\testgui.spec
93 INFO: UPX is not available.
95 INFO: Extending PYTHONPATH with paths
['C:\\PythonProjects\\firstGUI', 'C:\\PythonProjects\\firstGUI']
95 INFO: checking Analysis
95 INFO: Building Analysis because out00-Analysis.toc is non existent
95 INFO: Initializing module dependency graph...
97 INFO: Initializing module graph hooks...
98 INFO: Analyzing base_library.zip ...
2321 INFO: running Analysis out00-Analysis.toc
2323 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\xyz\appdata\local\programs\python\python35\python.exe
2539 WARNING: lib not found: api-ms-win-core-sysinfo-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2588 WARNING: lib not found: api-ms-win-core-memory-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2635 WARNING: lib not found: api-ms-win-core-localization-l1-2-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2682 WARNING: lib not found: api-ms-win-core-file-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2729 WARNING: lib not found: api-ms-win-core-handle-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2778 WARNING: lib not found: api-ms-win-core-rtlsupport-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2826 WARNING: lib not found: api-ms-win-core-util-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2875 WARNING: lib not found: api-ms-win-core-processenvironment-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2922 WARNING: lib not found: api-ms-win-core-file-l1-2-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
2968 WARNING: lib not found: api-ms-win-core-console-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3016 WARNING: lib not found: api-ms-win-core-errorhandling-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3062 WARNING: lib not found: api-ms-win-core-string-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3111 WARNING: lib not found: api-ms-win-core-processthreads-l1-1-1.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3158 WARNING: lib not found: api-ms-win-core-synch-l1-2-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3205 WARNING: lib not found: api-ms-win-core-file-l2-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3253 WARNING: lib not found: api-ms-win-core-datetime-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3300 WARNING: lib not found: api-ms-win-core-profile-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3346 WARNING: lib not found: api-ms-win-core-heap-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3394 WARNING: lib not found: api-ms-win-core-namedpipe-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3442 WARNING: lib not found: api-ms-win-core-processthreads-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3489 WARNING: lib not found: api-ms-win-core-synch-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3535 WARNING: lib not found: api-ms-win-core-debug-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3584 WARNING: lib not found: api-ms-win-core-timezone-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3630 WARNING: lib not found: api-ms-win-core-interlocked-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3678 WARNING: lib not found: api-ms-win-core-libraryloader-l1-1-0.dll dependency of C:\WINDOWS\system32\ucrtbase.dll
3741 INFO: Caching module hooks...
3745 INFO: Analyzing C:\PythonProjects\firstGUI\testgui.py
3773 INFO: Loading module hooks...
3773 INFO: Loading module hook "hook-xml.py"...
3946 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
3997 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
4301 INFO: Loading module hook "hook-pydoc.py"...
4302 INFO: Loading module hook "hook-PyQt5.py"...
4304 INFO: Loading module hook "hook-encodings.py"...
4377 INFO: Loading module hook "hook-PyQt5.Qt.py"...
4378 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
4380 INFO: Loading module hook "hook-PyQt5.QtPrintSupport.py"...
4449 INFO: Looking for ctypes DLLs
4450 INFO: Analyzing run-time hooks ...
4453 INFO: Including run-time hook 'pyi_rth_qt5.py'
4455 INFO: Including run-time hook 'pyi_rth_qt5plugins.py'
4460 INFO: Looking for dynamic libraries
4519 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
4569 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
4627 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\printsupport\windowsprintersupport.dll
4685 WARNING: lib not found: Qt5PrintSupport.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\printsupport\windowsprintersupport.dll
4734 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\printsupport\windowsprintersupport.dll
4789 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qicns.dll
4839 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qicns.dll
4898 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtga.dll
4948 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtga.dll
5012 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
5086 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
5145 WARNING: lib not found: Qt5Svg.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
5195 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
5245 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
5303 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qico.dll
5353 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qico.dll
5410 WARNING: lib not found: Qt5Svg.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
5460 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
5511 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
5568 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
5619 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
5678 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
5728 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
5789 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwebp.dll
5840 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwebp.dll
5895 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
5945 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
6003 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwbmp.dll
6053 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwbmp.dll
6115 WARNING: lib not found: Qt5Gui.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
6165 WARNING: lib not found: Qt5Core.dll dependency of C:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
6319 WARNING: lib not found: Qt5Core.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtCore.pyd
6383 WARNING: lib not found: Qt5Widgets.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtPrintSupport.pyd
6434 WARNING: lib not found: Qt5Gui.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtPrintSupport.pyd
6489 WARNING: lib not found: Qt5PrintSupport.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtPrintSupport.pyd
6538 WARNING: lib not found: Qt5Core.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtPrintSupport.pyd
6593 WARNING: lib not found: Qt5Gui.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtGui.pyd
6644 WARNING: lib not found: Qt5Core.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtGui.pyd
6703 WARNING: lib not found: Qt5Widgets.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtWidgets.pyd
6753 WARNING: lib not found: Qt5Gui.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtWidgets.pyd
6808 WARNING: lib not found: Qt5Core.dll dependency of c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyQt5\QtWidgets.pyd
6915 INFO: Looking for eggs
6915 INFO: Using Python library c:\users\xyz\appdata\local\programs\python\python35\python35.dll
6916 INFO: Found binding redirects:
[]
6922 INFO: Warnings written to C:\PythonProjects\firstGUI\build\testgui\warntestgui.txt
6930 INFO: checking PYZ
6931 INFO: Building PYZ because out00-PYZ.toc is non existent
6931 INFO: Building PYZ (ZlibArchive) C:\PythonProjects\firstGUI\build\testgui\out00-PYZ.pyz
7387 INFO: Building PYZ (ZlibArchive) C:\PythonProjects\firstGUI\build\testgui\out00-PYZ.pyz completed successfully.
7394 INFO: checking PKG
7394 INFO: Building PKG because out00-PKG.toc is non existent
7395 INFO: Building PKG (CArchive) out00-PKG.pkg
7411 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
7413 INFO: Bootloader c:\users\xyz\appdata\local\programs\python\python35\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
7413 INFO: checking EXE
7413 INFO: Building EXE because out00-EXE.toc is non existent
7414 INFO: Building EXE from out00-EXE.toc
7415 INFO: Appending archive to EXE C:\PythonProjects\firstGUI\build\testgui\testgui.exe
7421 INFO: Building EXE from out00-EXE.toc completed successfully.
7425 INFO: checking COLLECT
7425 INFO: Building COLLECT because out00-COLLECT.toc is non existent
7426 INFO: Building COLLECT out00-COLLECT.toc
7608 INFO: Building COLLECT out00-COLLECT.toc completed successfully.

【问题讨论】:

  • @StephenRauch 谢谢,但我已经看过了,并没有发现它很有帮助。也许我只是没有足够的经验,也许我只是厚,但我不知道如何确切地“使用 .spec 文件”或“实现一个新的钩子”。我将不胜感激任何帮助我的实际尝试。我以前从未这样做过。
  • 好的,我可以尝试提供帮助,但需要链接中注明的具体信息。在上述情况下,它无法找到 DLL。您是否在构建的同一台机器上运行?还要知道 QT 是通常难以正确处理的模块之一。还建议您查看 pyinstaller 错误跟踪器,看看是否有任何对您的情况有价值的东西。
  • @StephenRauch 感谢您的尝试!是的,我试图在我构建它的同一台机器上运行它。该程序本身在 Python 中运行良好。它实际上只是一个带有一些文本字段和几个按钮的小部件。我在上面的原始帖子下方发布了包装日志。我将尝试检查所有内容是否按照他们网站上描述的方式打包并报告。

标签: python-3.x pyinstaller pyqt5


【解决方案1】:

在您的驱动器上搜索丢失的文件并将其文件路径添加到您的环境变量路径数据(控制面板→系统→高级系统设置→环境变量)或构建:

pyinstaller --paths yourpathshere app.py

比如我的项目找到Qt5Core.dll和co如下:

pyinstaller --paths C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\PyQt5\Qt\bin app.py

【讨论】:

  • 我遇到了与 OP 相同的问题并尝试搜索这些文件,但在系统上找不到它们。
猜你喜欢
  • 2016-03-03
  • 1970-01-01
  • 2016-07-13
  • 2020-04-04
  • 2021-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-15
相关资源
最近更新 更多