Segmentation fault in "hello world" PyQt6 app on Mojave M1 mac

547 views
Skip to first unread message

Philip Queen

unread,
Jun 14, 2023, 3:44:01 PM6/14/23
to PyInstaller
Hello, 

# The Problem
I'm trying to create an executable for a simple "hello world" app built in PyQt6. I have tried the commands `pyinstaller hello_world.py`, `pyinstaller --onefile hello_world.py`, and `pyinstaller --windowed hello_world.py`, and the resulting executable always fails with a `zsh: segmentation fault`. I have also tried running it from `pyinstaller hello_world.spec` with the same result. 

# My Environment
I am using pyinstaller 5.12.0. I have also tried the download using `pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip`. I am using python 3.9.16 in a conda environment.
I have an M1 (arm64) mac running Monterey 12.6.2

# Additional Info
I have also tried running the above commands using the code from this conversation, where a user was able to get pyinstaller working with a pyqt6 gui on a Mojave, M1 mac: https://groups.google.com/g/pyinstaller/c/9lzdMY1eSrs/m/FyJoE9ljDwAJ

Let me know if there's any additional info that would help debug. I've tried all of the debugging steps I can find, but can't get off the ground with a working pyqt6 app.

# Files used
hello_world.py:
```
import sys
from PyQt6.QtWidgets import QApplication, QLabel, QWidget

app = QApplication(sys.argv)

window = QWidget()
window.setWindowTitle("Hello World")
window.setGeometry(100, 100, 300, 100)

hello_label = QLabel("<h1>Hello World!</h1>", parent=window)
hello_label.move(75, 30)

window.show()

sys.exit(app.exec())
```

hello_world.spec:
```
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(
    ['hello_world.py'],
    pathex=[],
    binaries=[],
    datas=[],
    hiddenimports=['PyQt6.QtWidgets'],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='hello_world',
    debug=True,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
```

bwoodsend

unread,
Jun 15, 2023, 12:16:21 PM6/15/23
to PyInstaller
PyQt6 doesn't support macOS < 11.0 now. And PyInstaller doesn't support macOS<10.15 unless you compile it from source. If you want to support old macOS versions, you should build on old macOS versions so that these issues are easy to diagnose.

Philip Queen

unread,
Jul 30, 2023, 3:44:05 AM7/30/23
to PyInstaller

Hi thanks for the response. Google didn't email me like I thought it would so I missed it, my apologies.

As I said in my original message though, I'm trying and failing to build on macOS=12.6.2, so I'm not too worried about the minimum support you mentioned. I would just like to be able to use pyinstaller to bundle my pyqt app, and it its segfaulting on even the most basic pyqt app.

Jurica Bacurin

unread,
Aug 15, 2023, 3:31:19 PM8/15/23
to PyInstaller
Hi,

I was also having trouble with that issue and finally yesterday found this issue on pyinstallers github issues: https://github.com/pyinstaller/pyinstaller/issues/7789
The latest pyinstaller release seems to process the Qt .framework bundles which leads to a broken Qt in the created package.

After switching to the develop branch and rebuilding the bootloader I can create app bundles with python 3.11 and PyQt 6.5.2 that work.

Hope this helps.

Philip Queen

unread,
Aug 16, 2023, 5:28:20 PM8/16/23
to PyInstaller

Thanks Jurica, that seems to be the exact problem I was facing!

Cheers!
Reply all
Reply to author
Forward
0 new messages