I am using QGIS 3.4.3-Madeira and OSX Mojave 10.14.3. I am trying to use QGIS 3 through the Python Console. I am following the QGIS 3 documentation.

I am trying to determine the syntax of the Split Vector Layer function. I entered this code into the QGIS Python Console:

import processing

I got this this syntax error:

    Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/code.py", line 64, in runsource
    code = self.compile(source, filename, symbol)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codeop.py", line 168, in __call__
    return _maybe_compile(self.compiler, source, filename, symbol)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codeop.py", line 99, in _maybe_compile
    raise err1
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codeop.py", line 87, in _maybe_compile
    code1 = compiler(source + "\n", filename, symbol)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codeop.py", line 133, in __call__
    codeob = compile(source, filename, symbol, self.flags, 1)
  File "<input>", line 1
SyntaxError: invalid syntax

I also tried the following but I got the same syntax error:

import processing

How do I find the syntax and parameters for this function?


Nearly there, you're just missing quotes:


Notice the " around the name of the function. This tells Python that the text you're passing to processing.algorithmHelp is a string. Without the quotes Python will attempt to interpret the text which is why you get a 'syntax error'.


Derp. I needed to add quotes like so:

import processing

Hope this helps somebody!

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.