6

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?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Mar 29, 2020 at 20:27

2 Answers 2

4

IMO best way to install QGIS plugin is qgis-plugin-manager. This is usage example:

pip3 install qgis-plugin-manager
mkdir -p ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins
cd ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins
qgis-plugin-manager init
qgis-plugin-manager update
qgis-plugin-manager install "your_plugin_name"

And then maybe you need to activate plugin. To do this, you should find in file ~/.local/share/QGIS/QGIS3/profiles/default/QGIS/QGIS3.ini line [PythonPlugins] and enable your plugin below, for example:

[PythonPlugins]
your_plugin_name=true

If you don't know exact your plugin name, you can find it after installation on a line starting with:

plugin_installer\seen_plugins=
etrimaille
7,57736 silver badges50 bronze badges
answered Aug 3, 2022 at 8:57
2
  • You need to fix qgis-plugin-master by qgis-plugin-manager. The link to the documentation of QGIS-Plugin-Manager : github.com/3liz/qgis-plugin-manager Commented Aug 3, 2022 at 9:53
  • I just edited your answer. Note for QGIS Server, plugins doesn't need to be activated in your ini file. Link to the documentation about installing plugins on a server docs.qgis.org/3.22/en/docs/server_manual/… Commented Aug 3, 2022 at 9:56
3

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)
answered Mar 30, 2020 at 3:34
2
  • 3
    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). Commented Mar 30, 2020 at 14:40
  • Only methods in QgsApplication with prefix 'install' are 'installEventFilter', 'installNativeEventFilter' and 'installTranslator'. You can search each one function. Commented Mar 30, 2020 at 14:58

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.