2

I am looking for a way to install and activate plugins in QGIS without accessing the GUI. I have a QGIS instance running on a remote server where I run standalone Python scripts that process the data.

I would like to install a couple of plugins so that I can run their algorithms using processing.run(). Either a command line or from Python script solution would work for me.

I had no luck searching through the documentation. Any suggestions?

2

For testing an approach, I arbitrarily chose "Append Features to Layer" and, with its link from plugins repository of QGIS:

https://plugins.qgis.org/plugins/AppendFeaturesToLayer/version/1.0.0/download/

by using following ariac command (aria package was previously installed in my GNU/Linux Debian):

aria2c -d /home/zeito/.local/share/QGIS/QGIS3/profiles/default/python/plugins https://plugins.qgis.org/plugins/AppendFeaturesToLayer/version/1.0.0/download/

it was successfully downloaded in plugin folder:

~/.local/share/QGIS/QGIS3/profiles/default/python/plugins

of my QGIS 3.12.1 as AppendFeaturesToLayer-1.0.0.zip. With command lines, I can unpack this zip file and run make, in plugin folder, for activating it before launching QGIS. So, I think it is possible to create a bash script for all process (downloading, unpacking and activating) for whatever plugin.

Editing Note:

With Python it was also possible. It's just a matter of making interactive following script.

from os import system

qgis_plugin_path = "/home/zeito/.local/share/QGIS/QGIS3/profiles/default/python/plugins"
qgis_plugin_repository = "https://plugins.qgis.org/plugins/AppendFeaturesToLayer/version/1.0.0/download/"

cmd = "aria2c -d " + qgis_plugin_path + " " + qgis_plugin_repository

system(cmd)
| improve this answer | |
  • While this approach is something that works, you need to know a lot besides the name of the plugin (i.e. current version) to get the correct link to download the file. I was wondering if there is a way to do something like QgsApplication.installPlugin("plugin_name). – Jan Caha Mar 30 at 14:40
  • Only methods in QgsApplication with prefix 'install' are 'installEventFilter', 'installNativeEventFilter' and 'installTranslator'. You can search each one function. – xunilk Mar 30 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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