More

How to install plugin through the python console in QGIS

How to install plugin through the python console in QGIS


I have been trying to load/install plugins via the python console in QGIS. After going through the documentation, I'm sure this is the way. I want to check if a plug-in is already installed, if not install it.

The lines:

from qgis import utils try: utils.isPluginLoaded('zoomtocoordinates') except ValueError: qgis.core.QgisInterface.addPluginToMenu('zoomtocoordinates')

The error returned:

Traceback (most recent call last): File "", line 1, in  AttributeError: 'module' object has no attribute 'QgisInterface'

QgisInterface is an abstract base class you cannot use this way. Call the addPluginToMenu method through the iface e.g. iface.addPluginToMenu(… ) The addPluginToMenu has two arguments, the second one is an action.


You have to load and start the plugin. From the QGIS python console, you can do:

from qgis import utils utils.loadPlugin('zoomtocoordinates') utils.startPlugin('zoomtocoordinates')

Watch the video: QGIS - Install plugins manually in offline mode