[QGIS-Developer] Issue running processing model from Python

Andreas Neumann a.neumann at carto.net
Tue Apr 24 23:35:20 PDT 2018


Hi, 

I want to run a model from Python code in QGIS 3.0x (recent nightly). 

Here is my code: 

------------------------------- 

def exportAnlagenAlsExcel():
    # Prepare processing framework
    from qgis.core import QgsProcessingFeatureSourceDefinition
    from processing.core.Processing import Processing
    Processing.initialize()
    import processing
    parameters = {'vfewsanlagen':
QgsProcessingFeatureSourceDefinition('Anlage', True),
'native:orderbyexpression_1:Ausgabedatei' : 'C:/temp/ews_anlagen.xlsx' }
    processing.run("model:Anlagen-Export",parameters,feedback=None)
    #open Resultatesfile in MS Excel
    command = 'start C:\\temp\\ews_anlagen.xlsx'
    os.system(command)
    iface.messageBar().pushInfo("Information",u"ExcelExport fertig") 

------------------- 

However, when running the script I get an error with a message I can't
interpret or solve: 

--------------- 

2018-04-25T08:09:51 WARNING Traceback (most recent call last): 

File "<string>", line 45, in exportAnlagenAlsExcel 

File
"C:/Programme/OSGeo4W64/apps/qgis-rel-dev/./python/plugins\processing\tools\general.py",
line 84, in run 

return Processing.runAlgorithm(algOrName, parameters, onFinish,
feedback, context) 

File
"C:/Programme/OSGeo4W64/apps/qgis-rel-dev/./python/plugins\processing\core\Processing.py",
line 193, in runAlgorithm 

raise QgsProcessingException(msg) 

_core.QgsProcessingException: There were errors executing the algorithm.


--------------------------- 

Do you know what is wrong in my Python code above? I am pretty sure that
the very same code ran in an older version of QGIS 3. 

Thank you for your help, 

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180425/f2d93e8e/attachment.html>


More information about the QGIS-Developer mailing list