MacOS BigSur 上的 Pyinstaller 无法构建基本的 PyQt5 应用程序
Pyinstaller on MacOS BigSur cannot build basic PyQt5 app
我正在尝试构建一个在 Big Sur 上使用 PyQt5 的非常基本的应用程序。
我使用最新的 pyinstaller 开发版本构建应用程序,没有出现错误,但是当我启动它时,它在启动后立即崩溃。
启动 exec,我在 app = QApplication(sys.argv)
.
之后立即出现分段错误
这是我的配置:
37 INFO: PyInstaller: 5.0.dev0
37 INFO: Python: 3.9.4
46 INFO: Platform: macOS-11.2.3-x86_64-i386-64bit
我的代码,用 python main.py
运行。这也不是应用程序使用的外部文件的问题,因为它在使用它们之前就崩溃了。
import os
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
DEBUG = True
if __name__ == "__main__":
if DEBUG:
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
print("Running in a Pyinstaller bundle.")
else:
print("Running in a normal Python process.")
for a in sys.argv:
print("sys.argv[]: {}".format(a))
print(sys.executable)
print(os.getcwd())
if DEBUG:
print("THIS RUNS")
app = QApplication([])
if DEBUG:
print("THIS DOESN'T")
win = QMainWindow()
win.setGeometry(200, 200, 300, 450)
win.setFixedSize(300, 450)
win.show()
sys.exit(app.exec_())
我使用的pyinstaller命令是:
pyinstaller --noconfirm --log-level=ERROR \
--clean \
--onefile \
--windowed \
--name Blabla \
--debug all \
--paths ~/PycharmProjects/FotoPDF/venv2/lib/python3.9/site-packages/ \
--paths ~/PycharmProjects/FotoPDF/venv2/ \
--paths ~/PycharmProjects/FotoPDF/venv2/lib/python3.9/site-packages/PyQt5/ \
--hidden-import PyQt5 \
--hidden-import PyQt5.sip \
--hidden-import PyQt5.QtWidgets \
--hidden-import PyQt5.QtGui \
--hidden-import PyQt5.QtCore \
main.py
想法?
这是我启动可执行文件时在终端中得到的内容:
(venv2) ste@ste FotoPDF % ./FotoPDF
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
import 'posix' # <class '_frozen_importlib.BuiltinImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook
import 'time' # <class '_frozen_importlib.BuiltinImporter'>
import 'zipimport' # <class '_frozen_importlib.FrozenImporter'>
# installed zipimport hook
# zipimport: found 147 names in '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip'
import '_codecs' # <class '_frozen_importlib.BuiltinImporter'>
import codecs # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/codecs.pyc
import encodings.aliases # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/aliases.pyc
import encodings # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/__init__.pyc
import encodings.utf_8 # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/utf_8.pyc
import encodings.ascii # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/ascii.pyc
import '_signal' # <class '_frozen_importlib.BuiltinImporter'>
import encodings.latin_1 # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/latin_1.pyc
import '_abc' # <class '_frozen_importlib.BuiltinImporter'>
import abc # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/abc.pyc
import io # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/io.pyc
# extension module '_struct' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_struct.cpython-39-darwin.so'
# extension module '_struct' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_struct.cpython-39-darwin.so'
import '_struct' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc30892c670>
# extension module 'zlib' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/zlib.cpython-39-darwin.so'
# extension module 'zlib' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/zlib.cpython-39-darwin.so'
import 'zlib' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc3089c7100>
# PyInstaller: FrozenImporter(/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/FotoPDF?60397)
import os # PyInstaller PYZ
import stat # PyInstaller PYZ
import '_stat' # <class '_frozen_importlib.BuiltinImporter'>
import 'stat' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# _collections_abc not found in PYZ
import _collections_abc # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/_collections_abc.pyc
import posixpath # PyInstaller PYZ
import genericpath # PyInstaller PYZ
import 'genericpath' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'posixpath' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'os' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import ctypes # PyInstaller PYZ
# types not found in PYZ
import types # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/types.pyc
# _ctypes not found in PYZ
# extension module '_ctypes' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_ctypes.cpython-39-darwin.so'
# extension module '_ctypes' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_ctypes.cpython-39-darwin.so'
import '_ctypes' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308b37d60>
import ctypes._endian # PyInstaller PYZ
import 'ctypes._endian' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'ctypes' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# ctypes.macholib not found in PYZ
# re not found in PYZ
# enum not found in PYZ
import enum # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/enum.pyc
# sre_compile not found in PYZ
import '_sre' # <class '_frozen_importlib.BuiltinImporter'>
# sre_parse not found in PYZ
# sre_constants not found in PYZ
import sre_constants # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/sre_constants.pyc
import sre_parse # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/sre_parse.pyc
import sre_compile # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/sre_compile.pyc
# functools not found in PYZ
# collections not found in PYZ
# heapq not found in PYZ
# _heapq not found in PYZ
# extension module '_heapq' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_heapq.cpython-39-darwin.so'
# extension module '_heapq' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_heapq.cpython-39-darwin.so'
import '_heapq' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308bbefa0>
import heapq # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/heapq.pyc
import 'itertools' # <class '_frozen_importlib.BuiltinImporter'>
# keyword not found in PYZ
import keyword # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/keyword.pyc
# operator not found in PYZ
import '_operator' # <class '_frozen_importlib.BuiltinImporter'>
import operator # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/operator.pyc
# reprlib not found in PYZ
import reprlib # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/reprlib.pyc
import '_collections' # <class '_frozen_importlib.BuiltinImporter'>
import collections # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/collections/__init__.pyc
import '_functools' # <class '_frozen_importlib.BuiltinImporter'>
import functools # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/functools.pyc
import '_locale' # <class '_frozen_importlib.BuiltinImporter'>
# copyreg not found in PYZ
import copyreg # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/copyreg.pyc
import re # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/re.pyc
import multiprocessing # PyInstaller PYZ
import multiprocessing.context # PyInstaller PYZ
import threading # PyInstaller PYZ
# _weakrefset not found in PYZ
import _weakrefset # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/_weakrefset.pyc
import 'threading' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.process # PyInstaller PYZ
import signal # PyInstaller PYZ
import 'signal' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.process' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.reduction # PyInstaller PYZ
import pickle # PyInstaller PYZ
import _compat_pickle # PyInstaller PYZ
import '_compat_pickle' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# _pickle not found in PYZ
# extension module '_pickle' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_pickle.cpython-39-darwin.so'
# extension module '_pickle' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_pickle.cpython-39-darwin.so'
import '_pickle' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308c985b0>
# org not found in PYZ
import 'pickle' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import socket # PyInstaller PYZ
# _socket not found in PYZ
# extension module '_socket' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_socket.cpython-39-darwin.so'
# extension module '_socket' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_socket.cpython-39-darwin.so'
import '_socket' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cbb2e0>
import selectors # PyInstaller PYZ
# collections.abc not found in PYZ
import collections.abc # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/collections/abc.pyc
# math not found in PYZ
# extension module 'math' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/math.cpython-39-darwin.so'
# extension module 'math' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/math.cpython-39-darwin.so'
import 'math' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cc6940>
# select not found in PYZ
# extension module 'select' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/select.cpython-39-darwin.so'
# extension module 'select' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/select.cpython-39-darwin.so'
import 'select' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cc69d0>
import 'selectors' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'errno' # <class '_frozen_importlib.BuiltinImporter'>
# array not found in PYZ
# extension module 'array' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/array.cpython-39-darwin.so'
# extension module 'array' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/array.cpython-39-darwin.so'
import 'array' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cd3640>
import 'socket' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.reduction' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.context' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.spawn # PyInstaller PYZ
import runpy # PyInstaller PYZ
import importlib # PyInstaller PYZ
# warnings not found in PYZ
import warnings # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/warnings.pyc
import 'importlib' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import importlib.machinery # PyInstaller PYZ
import 'importlib.machinery' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import importlib.util # PyInstaller PYZ
import importlib.abc # PyInstaller PYZ
import typing # PyInstaller PYZ
import contextlib # PyInstaller PYZ
import 'contextlib' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'typing' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'importlib.abc' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'importlib.util' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import pkgutil # PyInstaller PYZ
# weakref not found in PYZ
import weakref # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/weakref.pyc
import 'pkgutil' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'runpy' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.util # PyInstaller PYZ
import 'atexit' # <class '_frozen_importlib.BuiltinImporter'>
import subprocess # PyInstaller PYZ
import 'pwd' # <class '_frozen_importlib.BuiltinImporter'>
# grp not found in PYZ
# extension module 'grp' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/grp.cpython-39-darwin.so'
# extension module 'grp' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/grp.cpython-39-darwin.so'
import 'grp' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4940>
# msvcrt not found in PYZ
# _posixsubprocess not found in PYZ
# extension module '_posixsubprocess' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_posixsubprocess.cpython-39-darwin.so'
# extension module '_posixsubprocess' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_posixsubprocess.cpython-39-darwin.so'
import '_posixsubprocess' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4a30>
import 'subprocess' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.util' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.spawn' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.popen_fork # PyInstaller PYZ
import 'multiprocessing.popen_fork' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.popen_spawn_posix # PyInstaller PYZ
import 'multiprocessing.popen_spawn_posix' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import PyQt5 # PyInstaller PYZ
# possible namespace for /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5
import 'PyQt5' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# PyQt5.QtWidgets not found in PYZ
# PyQt5.sip not found in PYZ
# extension module 'PyQt5.sip' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/sip.cpython-39-darwin.so'
# extension module 'PyQt5.sip' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/sip.cpython-39-darwin.so'
import 'PyQt5.sip' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4eb0>
# PyQt5.QtCore not found in PYZ
# extension module 'PyQt5.QtCore' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtCore.abi3.so'
# extension module 'PyQt5.QtCore' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtCore.abi3.so'
import 'PyQt5.QtCore' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ebb100>
# PyQt5.QtGui not found in PYZ
# extension module 'PyQt5.QtGui' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtGui.abi3.so'
# extension module 'PyQt5.QtGui' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtGui.abi3.so'
import 'PyQt5.QtGui' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc30a8236a0>
# extension module 'PyQt5.QtWidgets' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtWidgets.abi3.so'
# extension module 'PyQt5.QtWidgets' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtWidgets.abi3.so'
import 'PyQt5.QtWidgets' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4c40>
Running in a Pyinstaller bundle.
sys.argv[]: ./FotoPDF
/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/FotoPDF
/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF
THIS RUNS
zsh: segmentation fault ./FotoPDF
暂时假设这不是 Pyinstaller 的错。
在 post 中,matplotlib 在 BigSur 更新后拒绝工作,直到重新安装。
并且 PyQt5 在 BigSur 更新后 this post 中没有显示任何 GUI。
如果 PyQt 有问题,那么修复应该是卸载并重新安装 PyQt5==5.15.2
pip uninstall PyQt5
pip install PyQt5== 5.15.2
然后设置
os.environ['QT_MAC_WANTS_LAYER'] = '1'
一位用户还说回滚到 PyQt5==5.12.0
解决了他的问题,所以也许可以试试。
如果问题出在 PyQt5 上,您还可以切换到 PySide2,这是 Qt5
的另一个绑定
如果问题出在 PyInstaller 上,您可以查看替代方案。
Python 3.5+ 通过 zipapp 提供 zip 支持,更多关于 here and here,它允许您使用命令将 python 程序归档到单个 .pyz
python -m zipapp myapp -m "myapp:main"
此命令运行是存档启动时模块 myapp 的主要功能。这可以简单地 运行 by-
python myapp.pyz
还有 py2app 类似于 pyinstaller 但特定于 macOS。
我正在尝试构建一个在 Big Sur 上使用 PyQt5 的非常基本的应用程序。
我使用最新的 pyinstaller 开发版本构建应用程序,没有出现错误,但是当我启动它时,它在启动后立即崩溃。
启动 exec,我在 app = QApplication(sys.argv)
.
这是我的配置:
37 INFO: PyInstaller: 5.0.dev0
37 INFO: Python: 3.9.4
46 INFO: Platform: macOS-11.2.3-x86_64-i386-64bit
我的代码,用 python main.py
运行。这也不是应用程序使用的外部文件的问题,因为它在使用它们之前就崩溃了。
import os
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
DEBUG = True
if __name__ == "__main__":
if DEBUG:
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
print("Running in a Pyinstaller bundle.")
else:
print("Running in a normal Python process.")
for a in sys.argv:
print("sys.argv[]: {}".format(a))
print(sys.executable)
print(os.getcwd())
if DEBUG:
print("THIS RUNS")
app = QApplication([])
if DEBUG:
print("THIS DOESN'T")
win = QMainWindow()
win.setGeometry(200, 200, 300, 450)
win.setFixedSize(300, 450)
win.show()
sys.exit(app.exec_())
我使用的pyinstaller命令是:
pyinstaller --noconfirm --log-level=ERROR \
--clean \
--onefile \
--windowed \
--name Blabla \
--debug all \
--paths ~/PycharmProjects/FotoPDF/venv2/lib/python3.9/site-packages/ \
--paths ~/PycharmProjects/FotoPDF/venv2/ \
--paths ~/PycharmProjects/FotoPDF/venv2/lib/python3.9/site-packages/PyQt5/ \
--hidden-import PyQt5 \
--hidden-import PyQt5.sip \
--hidden-import PyQt5.QtWidgets \
--hidden-import PyQt5.QtGui \
--hidden-import PyQt5.QtCore \
main.py
想法?
这是我启动可执行文件时在终端中得到的内容:
(venv2) ste@ste FotoPDF % ./FotoPDF
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
import 'posix' # <class '_frozen_importlib.BuiltinImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook
import 'time' # <class '_frozen_importlib.BuiltinImporter'>
import 'zipimport' # <class '_frozen_importlib.FrozenImporter'>
# installed zipimport hook
# zipimport: found 147 names in '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip'
import '_codecs' # <class '_frozen_importlib.BuiltinImporter'>
import codecs # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/codecs.pyc
import encodings.aliases # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/aliases.pyc
import encodings # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/__init__.pyc
import encodings.utf_8 # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/utf_8.pyc
import encodings.ascii # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/ascii.pyc
import '_signal' # <class '_frozen_importlib.BuiltinImporter'>
import encodings.latin_1 # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/encodings/latin_1.pyc
import '_abc' # <class '_frozen_importlib.BuiltinImporter'>
import abc # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/abc.pyc
import io # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/io.pyc
# extension module '_struct' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_struct.cpython-39-darwin.so'
# extension module '_struct' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_struct.cpython-39-darwin.so'
import '_struct' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc30892c670>
# extension module 'zlib' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/zlib.cpython-39-darwin.so'
# extension module 'zlib' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/zlib.cpython-39-darwin.so'
import 'zlib' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc3089c7100>
# PyInstaller: FrozenImporter(/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/FotoPDF?60397)
import os # PyInstaller PYZ
import stat # PyInstaller PYZ
import '_stat' # <class '_frozen_importlib.BuiltinImporter'>
import 'stat' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# _collections_abc not found in PYZ
import _collections_abc # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/_collections_abc.pyc
import posixpath # PyInstaller PYZ
import genericpath # PyInstaller PYZ
import 'genericpath' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'posixpath' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'os' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import ctypes # PyInstaller PYZ
# types not found in PYZ
import types # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/types.pyc
# _ctypes not found in PYZ
# extension module '_ctypes' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_ctypes.cpython-39-darwin.so'
# extension module '_ctypes' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_ctypes.cpython-39-darwin.so'
import '_ctypes' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308b37d60>
import ctypes._endian # PyInstaller PYZ
import 'ctypes._endian' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'ctypes' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# ctypes.macholib not found in PYZ
# re not found in PYZ
# enum not found in PYZ
import enum # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/enum.pyc
# sre_compile not found in PYZ
import '_sre' # <class '_frozen_importlib.BuiltinImporter'>
# sre_parse not found in PYZ
# sre_constants not found in PYZ
import sre_constants # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/sre_constants.pyc
import sre_parse # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/sre_parse.pyc
import sre_compile # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/sre_compile.pyc
# functools not found in PYZ
# collections not found in PYZ
# heapq not found in PYZ
# _heapq not found in PYZ
# extension module '_heapq' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_heapq.cpython-39-darwin.so'
# extension module '_heapq' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_heapq.cpython-39-darwin.so'
import '_heapq' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308bbefa0>
import heapq # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/heapq.pyc
import 'itertools' # <class '_frozen_importlib.BuiltinImporter'>
# keyword not found in PYZ
import keyword # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/keyword.pyc
# operator not found in PYZ
import '_operator' # <class '_frozen_importlib.BuiltinImporter'>
import operator # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/operator.pyc
# reprlib not found in PYZ
import reprlib # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/reprlib.pyc
import '_collections' # <class '_frozen_importlib.BuiltinImporter'>
import collections # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/collections/__init__.pyc
import '_functools' # <class '_frozen_importlib.BuiltinImporter'>
import functools # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/functools.pyc
import '_locale' # <class '_frozen_importlib.BuiltinImporter'>
# copyreg not found in PYZ
import copyreg # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/copyreg.pyc
import re # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/re.pyc
import multiprocessing # PyInstaller PYZ
import multiprocessing.context # PyInstaller PYZ
import threading # PyInstaller PYZ
# _weakrefset not found in PYZ
import _weakrefset # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/_weakrefset.pyc
import 'threading' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.process # PyInstaller PYZ
import signal # PyInstaller PYZ
import 'signal' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.process' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.reduction # PyInstaller PYZ
import pickle # PyInstaller PYZ
import _compat_pickle # PyInstaller PYZ
import '_compat_pickle' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# _pickle not found in PYZ
# extension module '_pickle' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_pickle.cpython-39-darwin.so'
# extension module '_pickle' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_pickle.cpython-39-darwin.so'
import '_pickle' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308c985b0>
# org not found in PYZ
import 'pickle' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import socket # PyInstaller PYZ
# _socket not found in PYZ
# extension module '_socket' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_socket.cpython-39-darwin.so'
# extension module '_socket' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_socket.cpython-39-darwin.so'
import '_socket' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cbb2e0>
import selectors # PyInstaller PYZ
# collections.abc not found in PYZ
import collections.abc # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/collections/abc.pyc
# math not found in PYZ
# extension module 'math' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/math.cpython-39-darwin.so'
# extension module 'math' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/math.cpython-39-darwin.so'
import 'math' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cc6940>
# select not found in PYZ
# extension module 'select' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/select.cpython-39-darwin.so'
# extension module 'select' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/select.cpython-39-darwin.so'
import 'select' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cc69d0>
import 'selectors' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'errno' # <class '_frozen_importlib.BuiltinImporter'>
# array not found in PYZ
# extension module 'array' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/array.cpython-39-darwin.so'
# extension module 'array' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/array.cpython-39-darwin.so'
import 'array' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308cd3640>
import 'socket' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.reduction' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.context' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.spawn # PyInstaller PYZ
import runpy # PyInstaller PYZ
import importlib # PyInstaller PYZ
# warnings not found in PYZ
import warnings # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/warnings.pyc
import 'importlib' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import importlib.machinery # PyInstaller PYZ
import 'importlib.machinery' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import importlib.util # PyInstaller PYZ
import importlib.abc # PyInstaller PYZ
import typing # PyInstaller PYZ
import contextlib # PyInstaller PYZ
import 'contextlib' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'typing' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'importlib.abc' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'importlib.util' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import pkgutil # PyInstaller PYZ
# weakref not found in PYZ
import weakref # loaded from Zip /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/base_library.zip/weakref.pyc
import 'pkgutil' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'runpy' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.util # PyInstaller PYZ
import 'atexit' # <class '_frozen_importlib.BuiltinImporter'>
import subprocess # PyInstaller PYZ
import 'pwd' # <class '_frozen_importlib.BuiltinImporter'>
# grp not found in PYZ
# extension module 'grp' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/grp.cpython-39-darwin.so'
# extension module 'grp' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/grp.cpython-39-darwin.so'
import 'grp' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4940>
# msvcrt not found in PYZ
# _posixsubprocess not found in PYZ
# extension module '_posixsubprocess' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_posixsubprocess.cpython-39-darwin.so'
# extension module '_posixsubprocess' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/lib-dynload/_posixsubprocess.cpython-39-darwin.so'
import '_posixsubprocess' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4a30>
import 'subprocess' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.util' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import 'multiprocessing.spawn' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.popen_fork # PyInstaller PYZ
import 'multiprocessing.popen_fork' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import multiprocessing.popen_spawn_posix # PyInstaller PYZ
import 'multiprocessing.popen_spawn_posix' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
import PyQt5 # PyInstaller PYZ
# possible namespace for /Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5
import 'PyQt5' # <pyimod03_importers.FrozenImporter object at 0x7fc3089c7a30>
# PyQt5.QtWidgets not found in PYZ
# PyQt5.sip not found in PYZ
# extension module 'PyQt5.sip' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/sip.cpython-39-darwin.so'
# extension module 'PyQt5.sip' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/sip.cpython-39-darwin.so'
import 'PyQt5.sip' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4eb0>
# PyQt5.QtCore not found in PYZ
# extension module 'PyQt5.QtCore' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtCore.abi3.so'
# extension module 'PyQt5.QtCore' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtCore.abi3.so'
import 'PyQt5.QtCore' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ebb100>
# PyQt5.QtGui not found in PYZ
# extension module 'PyQt5.QtGui' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtGui.abi3.so'
# extension module 'PyQt5.QtGui' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtGui.abi3.so'
import 'PyQt5.QtGui' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc30a8236a0>
# extension module 'PyQt5.QtWidgets' loaded from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtWidgets.abi3.so'
# extension module 'PyQt5.QtWidgets' executed from '/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/PyQt5/QtWidgets.abi3.so'
import 'PyQt5.QtWidgets' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc308ea4c40>
Running in a Pyinstaller bundle.
sys.argv[]: ./FotoPDF
/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF/FotoPDF
/Users/ste/PycharmProjects/FotoPDF/dist/FotoPDF
THIS RUNS
zsh: segmentation fault ./FotoPDF
暂时假设这不是 Pyinstaller 的错。
在
并且 PyQt5 在 BigSur 更新后 this post 中没有显示任何 GUI。
如果 PyQt 有问题,那么修复应该是卸载并重新安装 PyQt5==5.15.2
pip uninstall PyQt5
pip install PyQt5== 5.15.2
然后设置
os.environ['QT_MAC_WANTS_LAYER'] = '1'
一位用户还说回滚到 PyQt5==5.12.0
解决了他的问题,所以也许可以试试。
如果问题出在 PyQt5 上,您还可以切换到 PySide2,这是 Qt5
如果问题出在 PyInstaller 上,您可以查看替代方案。
Python 3.5+ 通过 zipapp 提供 zip 支持,更多关于 here and here,它允许您使用命令将 python 程序归档到单个 .pyz
python -m zipapp myapp -m "myapp:main"
此命令运行是存档启动时模块 myapp 的主要功能。这可以简单地 运行 by-
python myapp.pyz
还有 py2app 类似于 pyinstaller 但特定于 macOS。