I have an existing pyqgis standalone application that was developed using python2.7 and Qt4. Now that Qgis 3.0 has come out, I am trying to get it to run in Python 3.6 and Qt5. I've made a clean install of Qgis Desktop using OSGeo4W installer and desktop Qgis runs no problem and also can run the QgsApplication.initQgis() function without error. However, it failed in my standalone application. Please note that I've set the environment variables such that import qgis.core etc works without error in my standalone app. Basically, the following simple pyqgis program failed at QgsApplication.initQgis() line:

from qgis.core import QgsApplication, QgsVectorLayer
qgis_home = 'C:/OSGEO4W64/apps/qgis'
print("DBG:qgis_home=", qgis_home)
QgsApplication.setPrefixPath(qgis_home, True)
print (QgsApplication.showSettings())
except Exception as e:
    print("DBG:" + e)

The 'Python has stopped working' error gave the following details:

Problem Event Name: APPCRASH
Application Name: python.exe
Application Version:
Fault Module Name: Qt5Core.dll
Fault Module Version:
Exception Code: c0000005

I am running things on the same windows 7 box that my previous pyqgis 2.7 app has been running without issue.

Your Answer

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

Browse other questions tagged or ask your own question.