I need to select a specific layer in the layer tree before I run my python script. I have tried Activating layer by its name in PyQGIS? with the code
registry = QgsProject.instance() layer = registry.mapLayersByName("name")
but on the layer tree, there is no change of focus. The layer does not get selected. How can I accomplish that?