I´m trying to do some geoprocessing using the QGIS Sextante plugin outside of the QGIS application (and integrate it with different other libraries like arcpy, etc.).

import sys, os
from PyQt4.QtGui import QApplication
from qgis.core import *
import qgis.utils


import sextante
input = "D:/Python_Test/a.shp"
output = "D:/Python_Test/b.shp"

print "Finished!"

Unfortunately the process fails with the following error:

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:/Users/.../.qgis/python/plugins\sextante\core\Sextante.py", line 376, in runalg
    alg = Sextante.runAlgorithm(algOrName, None, *args)
  File "C:/Users/.../.qgis/python/plugins\sextante\core\Sextante.py", line 276, in runAlgorithm
    if not param.setValue(args[i]):
  File "C:/Users/.../.qgis/python/plugins\sextante\parameters\ParameterVector.py", line 59, in setValue
    layers = QGisLayers.getVectorLayers(self.shapetype)
  File "C:/Users/.../.qgis/python/plugins\sextante\core\QGisLayers.py", line 79, in getVectorLayers
    layers = QGisLayers.iface.legendInterface().layers()
AttributeError: 'NoneType' object has no attribute 'legendInterface'

What am I doing wrong? Sextante seems to be initialized correctly because


gives me

ALGORITHM: Convex hull
    INPUT <ParameterVector>
    FIELD <ParameterTableField from INPUT>
    METHOD <ParameterSelection>
    OUTPUT <OutputVector>

I´m using Windows 7 Professional 64Bit and the OsGeo4W installation with QGIS 1.8.0 and python 2.7.4.


There is a way of running QGIS processing algorithms in standalone PyQGIS scripts. Check answers to Import error for qgis.core when running OSGeo4w shell script and How can I access `processing` with Python?, which provide you with tested examples.

| improve this answer | |

The accepted answer to the following question answers this question as well:

Access Sextante (processing) in standalone QGIS app?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.