9

Hi everyone I'm in some way new with PyQGIS and I've been trying to run a script in QGIS 3.0 without success (it prefectly ran in 2.18) and always get the same error:

AttributeError: module 'processing' has no attribute 'runalg' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\PROGRA~1\QGIS3~1.0\apps\Python36\lib\code.py", line 91, in runcode exec(code, self.locals) File "", line 8, in TypeError: catching classes that do not inherit from BaseException is not allowed

Does this has something to do with PYTHONPATH? I can't even see the list of algorithms when typing: processing.alglist()

7

This is not an answer to the original question, but to a follow-up question in a comment ("Also how can I see the list and options of algorithms?").

In QGIS 3, the processing algorithms can be listed in the QGIS Python console (Python 3) using (see https://gis.stackexchange.com/a/274902/22646 and https://gis.stackexchange.com/a/274874/22646):

QgsApplication.processingRegistry().algorithms()

To list the names (IDs):

for alg in QgsApplication.processingRegistry().algorithms(): print(alg.id())

Getting help for an algorithm (including input parameters and output):

processing.algorithmHelp("qgis:union")

There is also:

processing.algs.help.shortHelp.keys()
print("\n".join(processing.algs.help.shortHelp.keys()))

But it does not seem to include algorithms from for instance gdal and grass.

13

In QGIS 3, use processing.run.

For instance:

QGIS 2.x processing.runalg('gdalogr:convertformat', ...

QGIS 3.0 processing.run('gdal:convertformat', ...

  • It works perfectly fine. Also how can I see the list and options of algorithms? I've tried processing.alglist() and processing.list() but both throw a similar error. – LE_Geomatica Mar 14 '18 at 17:28

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.