I have created a new plugin in QGIS3 with PyQt5 using Plugins Builder and when i want to add my code in module.py gives an error

the code used is

    layers = self.iface.legendInterface().layers()
    layer_list = []
    for layer in layers:


the error message is

AttributeError: 'QgisInterface' object has no attribute 'legendInterface' Traceback (most recent call last): File "C:/Users/REDADRISSI/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\reda\module.py", line 187, in run layers = self.iface.legendInterface().layers() AttributeError: 'QgisInterface' object has no attribute 'legendInterface'

  • Hello Kadir, thanks for your reaction, i tried this solution and gives another error NameError: name 'QgsProject' is not defined – REDA DRISSI Apr 18 '18 at 15:45
  • Adding from qgis.core import QgsProject will probably fix your problem. – Kadir Şahbaz Apr 18 '18 at 15:48

Browse other questions tagged or ask your own question.