1

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 "<input>", line 1, in <module>
AttributeError: 'module' object has no attribute 'QgisInterface'
asked Sep 12, 2015 at 22:58
1
  • 1
    addPluginToMenu will not load the plugin, it is usually used by the initgui method of a plugin. Commented Sep 13, 2015 at 8:13

2 Answers 2

1

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')
answered Sep 6, 2018 at 11:37
0

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.

answered Sep 13, 2015 at 8:09
2
  • What would be the action ? like trigger() Commented Sep 14, 2015 at 6:11
  • An action is a QAction object with icon, text and call back function. But again addPluginToMenu will not load the plugin. Commented Sep 15, 2015 at 11:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.