I'm trying to write a standalone script in qgis 2.10 in ubuntu I 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.7 from qgis.core import * from platform import python_version print python_version() # supply path to where is your qgis installed QgsApplication.setPrefixPath("/usr", True) # load providers QgsApplication.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(): pass print "hello" QgsApplication.exitQgis()
When I run from within the qgis DE I get:
2.7.6 105777 EPSG:2193 hello
When I run from bash I get:
2.7.6 105777 EPSG:2193 Segmentation 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? and given the response to the version function that seems unlikely. For the shebang I also tried
with the same result.