如使用python QT 设计UI程序,出现如图错误可进行如下尝试
;
2.到安装QT 依赖包路径下复制所有相关包到程序所在目录,如图:
3.先打包生成.spec文件
pyinstaller -F main_pdf_to_word_V1.1.py(换成你自己的主文件)
4.修改main_pdf_to_word_V1.1.spec文件中把所有QT相关依赖包都放在pathex=[]中,以列表形式存放,用逗号分割,如:
pathex=['PyQt5','pyqt5_plugins','PyQt5_Qt5-5.15.2.dist-info','PyQt5_sip-12.11.0.dist-info','pyqt5_tools','pyqt5_tools-5.15.4.3.2.dist-info','PyQt5-5.15.4.dist-info','qt5_applications','qt5_applications-5.15.2.2.2.dist-info','qt5_tools','qt5_tools-5.15.2.1.2.dist-info'],
- 去掉DOS窗口,修改文件中console=False
在这里插入代码片exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='main_pdf_to_word_V1.1',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
6.对.spec文件打包,打包后的exe 记包含所有依赖的QT包,这时再复制exe到其他电脑上,就都可以使用了,不会再报错了
pyinstaller main_pdf_to_word_V1.1.spec