# from PyQt5.QtWidgets import QApplication,QMainWindow import sys from PyQt5.QtWidgets import QApplication,QMainWindow from PyQt5 import QtCore,QtGui, QtWidgets if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv)----就这行,只要加了就异常 print('hi') # sys.exit(app.exec())
其实程序我已经缩减到最小了。就是为了发现错误,不过还是运行异常,不知道为啥,打包没有错误。app也能正常生成,就是运行异常。
应该是打包时遇到问题,你把把完包以后的命令窗口里的数据复制下来翻译来看看
pyinstaller -wFD main_5.py
111 INFO: PyInstaller: 4.3
112 INFO: Python: 3.8.3
123 INFO: Platform: macOS-10.16-x86_64-i386-64bit
124 INFO: wrote /Users/wq/work/qddesign做界面/main_5.spec
128 INFO: UPX is not available.
130 INFO: Extending PYTHONPATH with paths
['/Users/wq/work/qddesign做界面', '/Users/wq/work/qddesign做界面']
155 INFO: checking Analysis
155 INFO: Building Analysis because Analysis-00.toc is non existent
155 INFO: Initializing module dependency graph...
157 INFO: Caching module graph hooks...
163 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
167 INFO: Analyzing base_library.zip ...
3062 INFO: Processing pre-find module path hook distutils from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
3064 INFO: distutils: retargeting to non-venv dir '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
6115 INFO: Caching module dependency graph...
6316 INFO: running Analysis Analysis-00.toc
6324 INFO: Analyzing /Users/wq/work/qddesign做界面/main_5.py
6367 INFO: Processing module hooks...
6368 INFO: Loading module hook 'hook-PyQt5.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6526 WARNING: Hidden import "sip" not found!
6526 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6527 INFO: Loading module hook 'hook-lib2to3.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6573 INFO: Loading module hook 'hook-_tkinter.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6734 INFO: checking Tree
6734 INFO: Building Tree because Tree-00.toc is non existent
6734 INFO: Building Tree Tree-00.toc
6755 INFO: checking Tree
6755 INFO: Building Tree because Tree-01.toc is non existent
6755 INFO: Building Tree Tree-01.toc
6833 INFO: checking Tree
6834 INFO: Building Tree because Tree-02.toc is non existent
6834 INFO: Building Tree Tree-02.toc
6838 INFO: Loading module hook 'hook-encodings.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6901 INFO: Loading module hook 'hook-distutils.util.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6905 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6951 INFO: Loading module hook 'hook-pickle.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6953 INFO: Loading module hook 'hook-heapq.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6955 INFO: Loading module hook 'hook-difflib.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
6956 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
7006 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
7008 INFO: Loading module hook 'hook-sysconfig.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
7018 INFO: Loading module hook 'hook-xml.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
7092 INFO: Loading module hook 'hook-distutils.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
7093 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks'...
7117 INFO: Looking for ctypes DLLs
7151 INFO: Analyzing run-time hooks ...
7155 INFO: Including run-time hook '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
7160 INFO: Including run-time hook '/Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pyqt5.py'
7167 INFO: Looking for dynamic libraries
7493 INFO: Looking for eggs
7493 INFO: Using Python library /Library/Frameworks/Python.framework/Versions/3.8/Python
7497 INFO: Warnings written to /Users/wq/work/qddesign做界面/build/main_5/warn-main_5.txt
7526 INFO: Graph cross-reference written to /Users/wq/work/qddesign做界面/build/main_5/xref-main_5.html
7537 INFO: checking PYZ
7537 INFO: Building PYZ because PYZ-00.toc is non existent
7537 INFO: Building PYZ (ZlibArchive) /Users/wq/work/qddesign做界面/build/main_5/PYZ-00.pyz
8005 INFO: Building PYZ (ZlibArchive) /Users/wq/work/qddesign做界面/build/main_5/PYZ-00.pyz completed successfully.
8014 INFO: checking PKG
8014 INFO: Building PKG because PKG-00.toc is non existent
8014 INFO: Building PKG (CArchive) PKG-00.pkg
8029 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
8031 INFO: Bootloader /Users/wq/Library/Python/3.8/lib/python/site-packages/PyInstaller/bootloader/Darwin-64bit/runw
8031 INFO: checking EXE
8031 INFO: Building EXE because EXE-00.toc is non existent
8031 INFO: Building EXE from EXE-00.toc
8031 INFO: Appending archive to EXE /Users/wq/work/qddesign做界面/build/main_5/main_5
8034 INFO: Fixing EXE for code signing /Users/wq/work/qddesign做界面/build/main_5/main_5
8039 INFO: Building EXE from EXE-00.toc completed successfully.
8040 INFO: checking COLLECT
8041 INFO: Building COLLECT because COLLECT-00.toc is non existent
8041 INFO: Building COLLECT COLLECT-00.toc
9981 INFO: Building COLLECT COLLECT-00.toc completed successfully.
9986 INFO: checking BUNDLE
9986 INFO: Building BUNDLE because BUNDLE-00.toc is non existent
9986 INFO: Building BUNDLE BUNDLE-00.toc
11638 INFO: moving BUNDLE data files to Resource directory
这是打包的过程,似乎也没看到什么问题,我一直在想难道是因为mac版本是BigSlur?
看了一下你的打包数据。
1.128 信息:UPX 不可用。
pyinstaller需要upx压缩python文件
登陆upx官网下载相应版本的upx插件,将upx.exe放至.py文件目录下即可(官网下载不了就去百度一下其他平台下载)
2.155 信息:构建分析,因为 Analysis-00.toc 不存在
3.6526 警告:未找到隐藏的导入“sip”!
4.6734 信息:构建树,因为 Tree-00.toc 不存在
根据错误提示一步一步解决就好了。