Why are neither of the commands below returning details on the active layer method?

It works when I use the class iface.


This is the error I get

Traceback (most recent call last): File "C:\PROGRA~1\QGIS32~1.1\apps\Python39\lib\code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in NameError: name 'activeLayer' is not defined

1 Answer 1


This is because Python doesn't have activeLayer imported into the current namespace, so it can't find it. Its not just the help that doesn't work, nothing will find activeLayer:

enter image description here

It finds iface because that is imported for you.

enter image description here

You can do dir() to see what is imported. You can do dir(iface) to see what the iface object has for you.

So to get the help on the activeLayer object, you can do help(iface.activeLayer) since activeLayer is a property of iface and iface is imported.

enter image description here

  • Thanks that helped allot Commented Aug 11, 2022 at 23:44
  • 1
    @ChaceCarpenter If you like the answer and it was helpful, please consider upvoting by clicking on the arrows next to the score and/or marking it as the accepted answer by clicking on the checkmark ✓. Commented Aug 12, 2022 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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