YOLO5 开发了一个小应用,在Pycharm运行环境下,可以正常运行。使用Pyintaller打包成EXE后,运行报错:
Traceback (most recent call last):
File "PyInstaller\hooks\rthooks\pyi_rth_win32comgenpy.py", line 46, in <module>
File "PyInstaller\hooks\rthooks\pyi_rth_win32comgenpy.py", line 25, in _pyi_rthook
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "win32com\__init__.py", line 6, in <module>
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "pythoncom.py", line 3, in <module>
File "pywintypes.py", line 61, in __import_pywin32_system_module__
ImportError: Module 'pythoncom' isn't in frozen sys.path ['C:\\Users\\zhouzhiwei\\AppData\\Local\\Temp\\_MEI130882\\base_library.zip', 'C:\\Users\\zhouzhiwei\\AppData\\Local\\Temp\\_MEI130882\\lib-dynload', 'C:\\Users\\zhouzhiwei\\AppData\\Local\\Temp\\_MEI130882', 'C:\\Users\\zhouzhiwei\\AppData\\Local\\Temp\\_MEI130882\\win32', 'C:\\Users\\zhouzhiwei\\AppData\\Local\\Temp\\_MEI130882\\pythonwin', 'C:\\Users\\zhouzhiwei\\AppData\\Local\\Temp\\_MEI130882\\pywin32_system32']
[12208] Failed to execute script 'pyi_rth_win32comgenpy' due to unhandled exception!
确认了安装环境:
- win10
- python 版本 : 3.8.19 | packaged by conda-forge | (default, Mar 20 2024, 12:38:07) [MSC v.1929 64 bit (AMD64)] on win32
- Pyinstaller : 4.4版
- pywin32:225
- pypiwin32: 223
尝试了网上的各种方式,包括复制 pythoncom38.dll 到EXE根目录,也尝试 过pywin32:227、223,Pyinstaller : 5.0 ,还是一直报错。想请教下各位 有没有遇到过类似的问题。或者有没有python3.8打包EXE运行成功的,方不方便导出生成 All_Package.txt,我直接全部重装试试。