Wednesday 15 June 2016

Using standalone pyQGIS application QgsApplication.initQgis() fails?


I'm trying to execute the following code on a windows 7 system:


import qgis.core as qc
qgis_path = "C:\Program Files\QGIS Lyon\apps\qgis"

qc.QgsApplication.setPrefixPath(qgis_path, True)
qc.QgsApplication.initQgis()
print "Successfully Initialised"

The qc.QgsApplication.initQgis() command causes python to stop working. Can anyone help with the steps I need to diagnose this problem?


Some background:



  • I've tried a number of different combinations of forward slashes, escaped backslashes etc.for the path and still get the same error;

  • I've been developing the code (part of a larger application) on Linux, without problems;

  • A long time ago, I tested the code on Windows and it worked OK. At that time I had QGIS Dufour installed;


  • I suspect it may have something to do with having the correct environment variables set, but have been unable to find a definitive guide on which and how these variables need to be set.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...