I'm trying to write a standalone script in qgis 2.10 in ubuntuI have written a script which crashes when I run from bash but works fine from inside the qgis desktop environment. The script is:
#!/usr/bin/python2.7from qgis.core import *# supply path to where is your qgis installedQgsApplication.setPrefixPath("/usr", True)# load providersQgsApplication.initQgis()input_file = "/path/to/shape/file.shp"input_layer = QgsVectorLayer(input_file, "input layer", "ogr")QgsMapLayerRegistry.instance().addMapLayer(input_layer)print str(input_layer.featureCount())print input_layer.dataProvider().crs().authid()for feature in input_layer.getFeatures(): passprint "hello"QgsApplication.exitQgis()When I run from within the qgis DE I get:
105777EPSG:2193helloWhen I run from bash I get:
105777EPSG:2193Segmentation fault (core dumped)The only thing I can guess is my interpreter choice in my shebang but none of the python executables I can find make any difference?I've seen the docs on standalone scripts hereand I figured out the correct(?) path to the installation from here but I'm stumped as to the cause of this crash.
أكثر...
#!/usr/bin/python2.7from qgis.core import *# supply path to where is your qgis installedQgsApplication.setPrefixPath("/usr", True)# load providersQgsApplication.initQgis()input_file = "/path/to/shape/file.shp"input_layer = QgsVectorLayer(input_file, "input layer", "ogr")QgsMapLayerRegistry.instance().addMapLayer(input_layer)print str(input_layer.featureCount())print input_layer.dataProvider().crs().authid()for feature in input_layer.getFeatures(): passprint "hello"QgsApplication.exitQgis()When I run from within the qgis DE I get:
105777EPSG:2193helloWhen I run from bash I get:
105777EPSG:2193Segmentation fault (core dumped)The only thing I can guess is my interpreter choice in my shebang but none of the python executables I can find make any difference?I've seen the docs on standalone scripts hereand I figured out the correct(?) path to the installation from here but I'm stumped as to the cause of this crash.
أكثر...