0

When I'm trying to run a PySide6 application using app.exec(), the app crashes with the reason segmentation fault.

main.py:

import os.path
import sys
from PySide6.QtGui import QGuiApplication
from PySide6.QtQuick import QQuickView
from PySide6.QtCore import QUrl

app = QGuiApplication(sys.argv)
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)

qmlFile = os.path.join(os.path.dirname(__file__), 'view.qml')
url = QUrl.fromLocalFile(os.path.abspath(qmlFile))

view.setSource(url)
if view.status() == QQuickView.Error:
    sys.exit(-1)
view.show()

app.exec()

view.qml:

import QtQuick.Controls 2.15

Label {
    text: "Label"
}

I'm running PySide version 6.1 on Python 3.8.2 with macOS Big Sur

Qt Debug Log:

... Skipped 150 lines being the same as below ...

loaded library "/Users/nightloewe/PycharmProjects/QtTestApp/venv/lib/python3.8/site-packages/PySide6/Qt/qml/QtQuick/Templates/libqtquicktemplates2plugin.dylib"
Found metadata in lib /Users/nightloewe/PycharmProjects/QtTestApp/venv/lib/python3.8/site-packages/PySide6/Qt/qml/QtQuick/Controls/Fusion/impl/libqtquickcontrols2fusionstyleimplplugin.dylib, metadata=
{
    "IID": "org.qt-project.Qt.QQmlExtensionInterface/1.0",
    "archreq": 0,
    "className": "QtQuickControls2FusionStyleImplPlugin",
    "debug": false,
    "uri": [
        "QtQuick.Controls.Fusion.impl"
    ],
    "version": 393472
}


loaded library "/Users/nightloewe/PycharmProjects/QtTestApp/venv/lib/python3.8/site-packages/PySide6/Qt/qml/QtQuick/Controls/Fusion/impl/libqtquickcontrols2fusionstyleimplplugin.dylib"
QFactoryLoader::QFactoryLoader() checking directory path "/Users/nightloewe/PycharmProjects/QtTestApp/venv/lib/python3.8/site-packages/PySide6/Qt/plugins/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "/Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/accessible" ...
Segmentation fault: 11
Nightloewe
  • 918
  • 1
  • 14
  • 24
  • show the imports – eyllanesc Sep 29 '21 at 12:42
  • @eyllanesc I added the imports – Nightloewe Sep 29 '21 at 12:43
  • Are you using any special IDE or environment? Try running `QT_DEBUG_PLUGINS=1 python main.py` on the console. – eyllanesc Sep 29 '21 at 12:45
  • @eyllanesc I'm using PyCharm and it created a virtual environment using virtualenv – Nightloewe Sep 29 '21 at 12:47
  • Activate venv from the console and run the script from the console with the above command and share the log. – eyllanesc Sep 29 '21 at 12:49
  • @eyllanesc I added the the last lines of the log, the lines above were always loaded library, found metadata, etc. – Nightloewe Sep 29 '21 at 12:59
  • I cannot reproduce the problem on linux using qt 6.1.3 and pyside-6.1.3. So this could be caused by a bug in pyside6 or qt6 that only affects macos. I suggest you try testing with pyside2 or pyqt5/6 to confirm this. It might also be worth trying the example in [this SO question](https://stackoverflow.com/q/66492343/984421) to see if your problem is the same. – ekhumoro Sep 30 '21 at 12:14

0 Answers0