windows pyinstaller 安装时显示没有pythonxx.DLL/Pyinstaller:FormatMessageW failed/ xxx module 找不到

发布时间 2023-04-11 23:56:22作者: zdxxx

在使用pyinstaller打包时候可能显示出各种错误

1.windows pyinstaller 安装时显示没有pythonxx.DLL

 

2.Pyinstaller:FormatMessageW failed

 

 

 

 

3.module xxx  找不到

 

 

 

 

我来总结一下这些报错的可能解决方案

1.pythonxxx.DLL没有  解决方法:在网上下载对应的dll放到打包的根目录下

2.Pyinstaller:FormatMessageW failed  解决方法:同样的DLL可能有多种版本 挨个试 例如:python39.dll 免费下载 | DLL‑files.com (dll-files.com)

3.xxx module 找不到  解决方法:使用--hidden-import=xxx  例如:pyinstaller -D -w --add-data="./utils/*;./utils" --add-data="./config/*;./config" --add-data="./icon/*;./icon" --add-data="./pt/*;./pt" --add-data="./imgs/*;./imgs" main.py -F --hidden-import=pywt --hidden-import=pyimod02_importers 

    第三种方法运行程序会显示 

416364 INFO: checking EXE
416374 INFO: Rebuilding EXE-00.toc because main.exe missing
416374 INFO: Building EXE from EXE-00.toc
416375 INFO: Copying bootloader EXE to C:\Users\86183\Downloads\PyQt5-YOLOv5-yolov5_v6.1\PyQt5-YOLOv5-yolov5_v6.1\dist\main.exe.notanexecutable
416410 INFO: Copying icon to EXE
416411 INFO: Copying icons from ['C:\\ProgramData\\Anaconda3\\envs\\yolo\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
416434 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
416434 INFO: Writing RT_ICON 1 resource with 3752 bytes
416435 INFO: Writing RT_ICON 2 resource with 2216 bytes
416435 INFO: Writing RT_ICON 3 resource with 1384 bytes
416435 INFO: Writing RT_ICON 4 resource with 38188 bytes
416435 INFO: Writing RT_ICON 5 resource with 9640 bytes
416435 INFO: Writing RT_ICON 6 resource with 4264 bytes
416435 INFO: Writing RT_ICON 7 resource with 1128 bytes
416437 INFO: Copying 0 resources to EXE
416437 INFO: Embedding manifest in EXE
416438 INFO: Updating manifest in C:\Users\86183\Downloads\PyQt5-YOLOv5-yolov5_v6.1\PyQt5-YOLOv5-yolov5_v6.1\dist\main.exe.notanexecutable
416459 INFO: Updating resource type 24 name 1 language 0
416461 INFO: Appending PKG archive to EXE
420830 INFO: Fixing EXE headers
430471 INFO: Building EXE from EXE-00.toc completed successfully.

然后就可以了

4.其他可能的错误 python的版本和windows有关 所以请及时更换python对应windows 的版本