【PyQt】使用 pyinstaller 构建 exe

首先可能需要安装一下 PyInstaller:

pip install pyinstaller

PyInstaller 的官方文档:PyInstaller Manual
构建命令:

pyinstaller [opt] [要打包的程序.py]

可选的 opt 有:

  • -D, -–onedir 创建一个目录,包含exe文件,但会依赖很多文件(默认选项)。
  • -F, -–onefile 打包成一个exe文件。
  • -c, –console, –nowindowed 使用控制台,无界面(默认)
  • -w, -–windowed, –noconsole 使用窗口,无控制台

构建过程中得到的 WARNING 及解决方法:

  • ctypes imports are only supported using bare filenames
    去掉引用 DLL 前面的路径或是 ./
  • lib not found: mfc90.dll dependency of 路径\ControlCAN.dll
  • lib not found: MSVCR90.dll dependency of 路径\ControlCAN.dll
  • One binary added with two internal names.
    29025 WARNING: ('libGLESv2.dll',
     'D:\\python37\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
     'BINARY')
    
  • was placed previously at
    29026 WARNING: ('PyQt5\\Qt\\bin\\libGLESv2.dll',
     'D:\\python37\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
     'BINARY')
    
  • failed to execute script
    有人说是编码的问题,改成 GBK 试试……然而依旧不行
    λ pchcp
    活动代码页: 936
    

换自己的笔记本上打包,更不得了了……可能公司电脑什么乱七八糟的都装上了,所以对于依赖项感受不到,这换到新环境,问题一下子就暴露出来了

$ pyinstaller -Fw main.py
249 INFO: PyInstaller: 3.4
249 INFO: Python: 3.7.3
249 INFO: Platform: Windows-10-10.0.17763-SP0
265 INFO: wrote E:\qt\pyqt\CANdataSender\main.spec
265 INFO: UPX is not available.
281 INFO: Extending PYTHONPATH with paths
['E:\\qt\\pyqt\\CANdataSender', 'E:\\qt\\pyqt\\CANdataSender']
281 INFO: checking Analysis
281 INFO: Building Analysis because Analysis-00.toc is non existent
296 INFO: Initializing module dependency graph...
296 INFO: Initializing module graph hooks...
296 INFO: Analyzing base_library.zip ...
8202 INFO: running Analysis Analysis-00.toc
8265 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\python.exe
8311 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\python.exe
8405 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\python.exe
8468 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\python.exe
8514 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\python.exe
8577 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\python\python.exe
8655 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8702 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8764 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8811 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8874 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\VCRUNTIME140.dll
8983 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\python37.dll
9030 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\python37.dll
9093 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\python\python37.dll
9155 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\python37.dll
9202 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\python37.dll
9264 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\python\python37.dll
9311 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\python37.dll
9374 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\python37.dll
9436 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\python37.dll
9483 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\python\python37.dll
9546 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\python37.dll
9608 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\python\python37.dll
9639 INFO: Caching module hooks...
9639 INFO: Analyzing E:\qt\pyqt\CANdataSender\main.py
9764 INFO: Loading module hooks...
9764 INFO: Loading module hook "hook-encodings.py"...
9936 INFO: Loading module hook "hook-pydoc.py"...
9936 INFO: Loading module hook "hook-PyQt5.py"...
10452 WARNING: Hidden import "sip" not found!
10452 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
11342 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
13624 INFO: Loading module hook "hook-xml.py"...
14139 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
15030 INFO: Looking for ctypes DLLs
15030 INFO: Analyzing run-time hooks ...
15045 INFO: Including run-time hook 'pyi_rth_qt5.py'
15045 INFO: Looking for dynamic libraries
15155 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libEGL.dll
15389 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platformthemes\qxdgdesktopportal.dll
15451 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platformthemes\qxdgdesktopportal.dll
15545 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwebp.dll
15608 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwebp.dll
15670 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwebp.dll
15717 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwebp.dll
15858 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
15905 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qsvg.dll
15998 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
16061 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
16123 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
16170 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
16233 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qjpeg.dll
17279 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qico.dll
17342 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qico.dll
17420 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtga.dll
17483 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtga.dll
17545 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtga.dll
17608 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
17670 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
17733 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
17795 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
17842 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
17904 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
17967 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
18029 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qminimal.dll
18139 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18201 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18264 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18311 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18373 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18436 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18498 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18561 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwindows.dll
18670 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
18717 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
18779 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
18842 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
18889 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
18951 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
19014 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
19076 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qoffscreen.dll
19170 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwbmp.dll
19217 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qwbmp.dll
19311 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19373 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19436 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19482 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19545 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19607 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19654 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19717 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qtiff.dll
19826 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
19873 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
19967 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
20029 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
20076 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
20139 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
20201 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
20357 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\styles\qwindowsvistastyle.dll
20420 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\styles\qwindowsvistastyle.dll
20592 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qicns.dll
20639 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qicns.dll
20701 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qicns.dll
20826 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
20873 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\iconengines\qsvgicon.dll
20951 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwebgl.dll
21232 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwebgl.dll
21295 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwebgl.dll
21357 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwebgl.dll
21420 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\platforms\qwebgl.dll
21529 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
21576 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
21639 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\plugins\imageformats\qgif.dll
21717 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
21795 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
21873 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\_ssl.pyd
21935 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
21998 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
22060 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
22107 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
22170 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\pyexpat.pyd
22279 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\unicodedata.pyd
22342 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\unicodedata.pyd
22404 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\unicodedata.pyd
22482 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_hashlib.pyd
22560 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
22623 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
22685 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
22748 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
22795 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\_bz2.pyd
22873 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\_lzma.pyd
22935 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_lzma.pyd
22998 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_socket.pyd
23060 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\_socket.pyd
23123 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\select.pyd
23185 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtCore.pyd
23248 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtCore.pyd
23310 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtCore.pyd
23373 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtCore.pyd
23451 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\sip.pyd
23513 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\sip.pyd
23560 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\sip.pyd
23623 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\sip.pyd
23685 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtWidgets.pyd
23748 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtWidgets.pyd
23826 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtGui.pyd
23888 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\QtGui.pyd
23982 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\_ctypes.pyd
24045 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\_ctypes.pyd
24107 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\_ctypes.pyd
24170 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
24216 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
24279 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
24341 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
24404 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
24451 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
24513 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\libGLESv2.dll
24576 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5dbus.dll
24638 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5dbus.dll
24685 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5dbus.dll
24795 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
24857 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
24920 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
24982 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
25029 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
25091 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
25154 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
25201 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5gui.dll
25295 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25357 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25404 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25466 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25529 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25591 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25638 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25701 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25763 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25826 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5core.dll
25888 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5svg.dll
25951 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5svg.dll
26013 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5svg.dll
26076 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5svg.dll
26169 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26232 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26294 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26341 WARNING: lib not found: api-ms-win-crt-multibyte-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26404 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26466 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26513 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26576 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26638 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26701 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26748 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26810 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of C:\python\lib\site-packages\PyQt5\Qt\bin\MSVCP140.dll
26888 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5widgets.dll
26951 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5widgets.dll
27013 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5widgets.dll
27076 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5widgets.dll
27185 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5quick.dll
27310 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5quick.dll
27372 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5quick.dll
27435 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5quick.dll
27482 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5quick.dll
27544 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5quick.dll
27607 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5websockets.dll
27669 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5websockets.dll
27779 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5network.dll
27826 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5network.dll
27888 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5network.dll
27951 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5network.dll
28013 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\qt5network.dll
28138 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28201 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28263 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28326 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28372 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28435 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28497 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28544 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28607 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\libcrypto-1_1-x64.dll
28747 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\python\DLLs\libssl-1_1-x64.dll
28810 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\DLLs\libssl-1_1-x64.dll
28857 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\DLLs\libssl-1_1-x64.dll
28919 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\DLLs\libssl-1_1-x64.dll
29107 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\Qt5Qml.dll
29154 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\Qt5Qml.dll
29216 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\Qt5Qml.dll
29279 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\Qt5Qml.dll
29341 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\Qt5Qml.dll
29388 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\python\lib\site-packages\PyQt5\Qt\bin\Qt5Qml.dll
29388 INFO: Looking for eggs
29404 INFO: Using Python library c:\python\python37.dll
29404 INFO: Found binding redirects:
[]
29404 INFO: Warnings written to E:\qt\pyqt\CANdataSender\build\main\warn-main.txt
29482 INFO: Graph cross-reference written to E:\qt\pyqt\CANdataSender\build\main\xref-main.html
29529 INFO: checking PYZ
29529 INFO: Building PYZ because PYZ-00.toc is non existent
29529 INFO: Building PYZ (ZlibArchive) E:\qt\pyqt\CANdataSender\build\main\PYZ-00.pyz
30075 INFO: Building PYZ (ZlibArchive) E:\qt\pyqt\CANdataSender\build\main\PYZ-00.pyz completed successfully.
30091 INFO: checking PKG
30091 INFO: Building PKG because PKG-00.toc is non existent
30091 INFO: Building PKG (CArchive) PKG-00.pkg
31888 WARNING: One binary added with two internal names.
31888 WARNING: ('libGLESv2.dll',
 'C:\\python\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
 'BINARY')
31888 WARNING: was placed previously at
31888 WARNING: ('PyQt5\\Qt\\bin\\libGLESv2.dll',
 'C:\\python\\lib\\site-packages\\PyQt5\\Qt\\bin\\libGLESv2.dll',
 'BINARY')
44278 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
44293 INFO: Bootloader c:\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
44293 INFO: checking EXE
44293 INFO: Building EXE because EXE-00.toc is non existent
44293 INFO: Building EXE from EXE-00.toc
44293 INFO: Appending archive to EXE E:\qt\pyqt\CANdataSender\dist\main.exe
44512 INFO: Building EXE from EXE-00.toc completed successfully.

打包完,到 dist 文件夹里找 main.exe 打开运行,果然显示 Failed to execute script main

然后就发现 ControlCAN.dll 依赖于 Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package MFC 安全更新(至于可能遇到缺失其他的依赖库的情况,可以到这里去找:https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads

然后至于上面那些 lib not found: api-ms-win-crt-啥啥啥 的警告,原来缺失的相关库文件路径在这里:C:\Windows\System32\downlevel
解决这个问题的方法:

  1. pyinstaller -p C:\Windows\System32\downlevel xxx(xxx:你要打包的项目)
  2. 或者是直接跑到这个目录下,把里面所有的 dll 文件全复制过来

至于 Hidden import "sip" not found! 的警告,貌似这个包没啥用,可以用以下方法屏蔽掉:
pyinstaller -p C:\Windows\System32\downlevel -Fw main.py --hidden-import=PyQt5.sip

猜你喜欢

转载自blog.csdn.net/weixin_34223655/article/details/90957931