J'essaie de construire une application très basique qui utilise PyQt5 sur Big Sur.
En utilisant la dernière version de développement de pyinstaller, je construis l'application sans erreur mais, lorsque je la lance, elle se bloque immédiatement après le démarrage. En lançant l'exécution, j'obtiens une erreur de segmentation juste après le lancement de l'application. app = QApplication(sys.argv)
.
Voici ma configuration :
37 INFO: PyInstaller: 5.0.dev0
37 INFO: Python: 3.9.4
46 INFO: Platform: macOS-11.2.3-x86_64-i386-64bit
Mon code, lancé avec python main.py
fonctionne. Ce n'est pas non plus un problème de fichiers externes utilisés par l'application car elle se plante bien avant de les utiliser.
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_())
La commande pyinstaller que j'utilise est :
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
Des idées ?
Voici ce que j'obtiens dans le terminal lorsque je lance l'exécutable :
(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