I am trying to run the default script that PyQGIS Cookbook provides along with adding few lines to read my project. It tries to read the read project but at the end gives a Segmentation Fault. How can I fix this?

import sys

from qgis.core import *

# supply path to qgis install location
QgsApplication.setPrefixPath("/Applications/QGIS3.app/Contents/MacOS", True)

# create a reference to the QgsApplication, setting the
# second argument to False disables the GUI
qgs = QgsApplication([], False)

# load providers

project = QgsProject.instance()

# Write your code here to load some layers, use processing
# algorithms, etc.

# When your script is complete, call exitQgis() to remove the
# provider and layer registries from memory


I actually found the way to do it. You have to set this:

export QT_QPA_PLATFORM_PLUGIN_PATH=/Applications/QGIS3.app/Contents/Plugins/platforms/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.