0

My Python window crashes after running this script. I have tested and it stops specifically at the qgs.initQgis() line.

I think that something changed in qgis from QGIS 2.18 to QGIS 3.4 where I need to change something with the path, but I can't quite figure that out.

import sys
from qgis.core import *
from qgis.gui import *
import qgis.utils
from qgis.core import QgsApplication


qgis_path = "C:\\Program Files\\QGIS 3.4"
QgsApplication.setPrefixPath(qgis_path, True)
qgs = QgsApplication([], False)
qgs.initQgis()

project = QgsProject.instance()

project.read('C:\\Users\\annam\\Desktop\\test.qgz')

layer = QgsVectorLayer('C:\\Users\\annam\\Downloads\\waterbodies\\arcimports\\kerr_225.shp', 'name', 'ogr')

project.addMapLayer(layer)

project.write()

qgs.exitQgis()

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.