求帮助!pyinstaller打包的exe文件运行时闪退,没有任何错误提示,如何解决?(语言-python)


D:\stock\dist>cd main_stock

D:\stock\dist\main_stock>main_stock
[7452] PyInstaller Bootloader 5.x
[7452] LOADER: executable is D:\stock\dist\main_stock\main_stock.exe
[7452] LOADER: homepath is D:\stock\dist\main_stock
[7452] LOADER: _MEIPASS2 is NULL
[7452] LOADER: archivename is D:\stock\dist\main_stock\main_stock.exe
[7452] LOADER: Cookie found at offset 0xAE8576
[7452] LOADER: No need to extract files to run; setting extractionpath to homepath
[7452] LOADER: SetDllDirectory(D:\stock\dist\main_stock)
[7452] LOADER: Already in the child - running user's code.
[7452] LOADER: Python library: D:\stock\dist\main_stock\python311.dll
[7452] LOADER: Loaded functions from Python library.
[7452] LOADER: Manipulating environment (sys.path, sys.prefix)
[7452] LOADER: sys.prefix is D:\stock\dist\main_stock
[7452] LOADER: Pre-init sys.path is D:\stock\dist\main_stock\base_library.zip;D:\stock\dist\main_stock\lib-dynload;D:\stock\dist\main_stock
[7452] LOADER: Setting runtime options
[7452] LOADER: Initializing python
[7452] LOADER: Overriding Python's sys.path
[7452] LOADER: Post-init sys.path is D:\stock\dist\main_stock\base_library.zip;D:\stock\dist\main_stock\lib-dynload;D:\stock\dist\main_stock
[7452] LOADER: Setting sys.argv
[7452] LOADER: setting sys._MEIPASS
[7452] LOADER: importing modules from CArchive
[7452] LOADER: extracted struct
[7452] LOADER: running unmarshalled code object for struct...
[7452] LOADER: extracted pyimod01_archive
[7452] LOADER: running unmarshalled code object for pyimod01_archive...
[7452] LOADER: extracted pyimod02_importers
[7452] LOADER: running unmarshalled code object for pyimod02_importers...
[7452] LOADER: extracted pyimod03_ctypes
[7452] LOADER: running unmarshalled code object for pyimod03_ctypes...
[7452] LOADER: extracted pyimod04_pywin32
[7452] LOADER: running unmarshalled code object for pyimod04_pywin32...
[7452] LOADER: Installing PYZ archive with Python modules.
[7452] LOADER: PYZ archive: PYZ-00.pyz
[7452] LOADER: Running pyiboot01_bootstrap.py
[7452] LOADER: Running pyi_rth_inspect.py
[7452] LOADER: Running pyi_rth_pkgutil.py
[7452] LOADER: Running pyi_rth_pkgres.py
[7452] LOADER: Running pyi_rth_pyqt5.py
[7452] LOADER: Running pyi_rth_mplconfig.py
[7452] LOADER: Running pyi_rth_multiprocessing.py
[7452] LOADER: Running pyi_rth_pyqt5webengine.py
[7452] LOADER: Running main_stock.py

D:\stock\dist\main_stock>

在build文件夹下的warn.txt文件 中显示许多missing module named ***, 这些库我的程序中并不需要导入。

你先写一个什么功能都没有,只有一行print的,看看是否能打包
然后不断添加你真实程序的 inport
看看是哪个模块导致了打包失败

pyinstaller打包时提示:


1299 WARNING: lib not found: ucrtbased.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DRenderd.dll
1309 WARNING: lib not found: VCRUNTIME140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DRenderd.dll
1309 WARNING: lib not found: MSVCP140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DRenderd.dll
1319 WARNING: lib not found: Qt5Cored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DRenderd.dll
1319 WARNING: lib not found: Qt53DCored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DRenderd.dll
1329 WARNING: lib not found: Qt5Guid.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DRenderd.dll
1329 WARNING: lib not found: Qt5Concurrentd.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DRenderd.dll
1379 WARNING: lib not found: ucrtbased.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DRenderd.dll
1379 WARNING: lib not found: VCRUNTIME140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DRenderd.dll
1389 WARNING: lib not found: MSVCP140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DRenderd.dll
1399 WARNING: lib not found: Qt5Cored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DRenderd.dll
1399 WARNING: lib not found: Qt53DCored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DRenderd.dll
1409 WARNING: lib not found: Qt5Guid.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DRenderd.dll
1409 WARNING: lib not found: Qt5Concurrentd.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DRenderd.dll
1479 WARNING: lib not found: ucrtbased.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DInputd.dll
1479 WARNING: lib not found: VCRUNTIME140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DInputd.dll
1489 WARNING: lib not found: Qt5Gamepadd.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DInputd.dll
1489 WARNING: lib not found: MSVCP140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DInputd.dll
1499 WARNING: lib not found: Qt5Cored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DInputd.dll
1509 WARNING: lib not found: Qt53DCored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DInputd.dll
1509 WARNING: lib not found: Qt5Guid.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\Qt53DInputd.dll
2226 WARNING: lib not found: Qt53DCore.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
2226 WARNING: lib not found: Qt53DRender.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
2236 WARNING: lib not found: Qt53DInput.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
2392 WARNING: lib not found: Qt53DCore.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\qtquickscene2dplugin.dll
2402 WARNING: lib not found: Qt53DRender.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene2D\qtquickscene2dplugin.dll
2662 WARNING: lib not found: ucrtbased.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DInputd.dll
2672 WARNING: lib not found: VCRUNTIME140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DInputd.dll
2672 WARNING: lib not found: Qt5Gamepadd.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DInputd.dll
2682 WARNING: lib not found: MSVCP140D.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DInputd.dll
2682 WARNING: lib not found: Qt5Cored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DInputd.dll
2692 WARNING: lib not found: Qt53DCored.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DInputd.dll
2692 WARNING: lib not found: Qt5Guid.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\qml\QtQuick\Scene3D\Qt53DInputd.dll
4689 WARNING: lib not found: Qt53DCore.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\bin\Qt53DAnimation.dll
4689 WARNING: lib not found: Qt53DRender.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\bin\Qt53DAnimation.dll
4719 WARNING: lib not found: Qt53DCore.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\bin\Qt53DLogic.dll
4739 WARNING: lib not found: Qt53DCore.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\bin\Qt53DQuickScene2D.dll
4749 WARNING: lib not found: Qt53DRender.dll dependency of E:\python\Lib\site-packages\PyQt5\Qt5\bin\Qt53DQuickScene2D.dll

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 这篇博客: python打包exe——pyinstaller遇到的那些坑及解决办法中的 问题三:ModuleNotFoundError: No module named ‘xxx’ 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:

    1.打包问题

    ModuleNotFoundError: No module named ‘xxx’
    

    依赖有第三方库的打包

    -p 后面跟着的是第三方库的路径(这里我直接把整个site-package都集成到exe里面了)【 如果包含多个目录,则可以用分号隔开: 】

    pyinstaller -F -p D:\K_Learning\pythonFiles\airtest_script\venv\Lib\site-packages devicesConnect.py
    
    

    如何查看当前代码所依赖的第三方库的路径:

    在这里插入图片描述


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^