I am trying to get started with pyQGIS but failing pretty hard.
Trying to follow http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html
A lot of it seems incomplete for Windows users, especially if they happen to have another python install...
C:\Python27\; C:\Python27\Scripts; C:\Program Files\QGIS Pisa\bin; C:\Program Files\QGIS Pisa\apps\qgis\bin;
C:\Program Files\QGIS Pisa\apps\qgis\python; C:\Program Files\QGIS Pisa\apps\qgis\python\plugins; C:\Program Files\QGIS Pisa\apps\Python27\lib\
from qgis.core import * # supply path to where is your qgis installed QgsApplication.setPrefixPath("C:/program files/qgis pisa/apps/qgis", True) # load providers QgsApplication.initQgis() data_source = "..." #many different files. layer_name = "nctasdfasd" provider_name = "ogr" layer = QgsVectorLayer(data_source, layer_name, provider_name) if not layer.isValid(): print "Layer failed to load!" QgsApplication.exitQgis()
/cygdrive/c/Program\ Files/QGIS\ Pisa/bin/python.exe test.py
(Have tried from cygwin and win cmd - no diff)
If i leave the shapefile zipped, get some warnings about recoding CP_OEMCP to UTF-8. If i unzip and point at .shp file, no output. If i run in cygwin, get "Segmentation fault", If i run in cmd, get windows crash dialog.
random census data from census.gov cb_2014_us_cd114_500k
Is there any way to get more information about the crash/failure? Getting to this point took a long time fighting silent errors about the python env and qgis prefixpath. I suspect there may still be an issue there, but don't know how to test/debug.
Edit: this is unlikely to help, but I upgraded to Essen and attached VS2015 to get a call stack. Is there a debug release available so I could get symbol names?
QtCore4.dll!00000000720d1e10() Unknown qca.dll!00007ff84af58af7() Unknown qca.dll!00007ff84af5dec7() Unknown qca.dll!00007ff84af5e5c3() Unknown qca.dll!00007ff84af41d74() Unknown qgis_core.dll!00007ff840a9305f() Unknown qgis_core.dll!00007ff840a9841f() Unknown _core.pyd!00007ff84160dba9() Unknown python27.dll!000000001e0c20a9() Unknown python27.dll!000000001e112524() Unknown python27.dll!000000001e115cd4() Unknown python27.dll!000000001e1174d9() Unknown python27.dll!000000001e117579() Unknown python27.dll!000000001e143a9a() Unknown python27.dll!000000001e144d8a() Unknown python27.dll!000000001e1453e0() Unknown python27.dll!000000001e145e23() Unknown python27.dll!000000001e044c25() Unknown python.exe!000000001d00119e() Unknown
More edits: By adding this statement before setPrefix:
app=QgsApplication( , False)
I got another error message about the GDAL_DATA env which I set to
C:\Program Files\QGIS Essen\share\epsg_csv
However, I still cannot load a layer. Still just crashing.