Skip to content

Instantly share code, notes, and snippets.

@spara
Created September 29, 2011 15:35
Show Gist options
  • Save spara/1251012 to your computer and use it in GitHub Desktop.
Save spara/1251012 to your computer and use it in GitHub Desktop.
QGIS standalone python script template for OSX
# To run the script you must set PYTHONPATH and path to QGIS binaries
#
# on Linux: export PYTHONPATH=/qgispath/share/qgis/python
# on Windows: set PYTHONPATH=c:\qgispath\python
# on OSX: export PYTHONPATH=/Applications/QGIS.app/Contents/Resources/python
# export PATH="/Applications/QGIS.app/Contents/MacOS/bin:$PATH"
from qgis.core import *
import sys
import os
# supply path to where is your qgis installed
QgsApplication.setPrefixPath("/Applications/QGIS.app/Contents/MacOS/", True)
# load providers
QgsApplication.initQgis()
# main routine
def main():
# code
# main
if __name__ == '__main__':
main()
QgsApplication.exitQgis()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment