I'm trying to run the RVT Plugin algorithms via a headless version of QGIS, on a server running Ubuntu 19.01.

I'm using the conda distribution of QGIS 3.18.2, installed in it's own environment using conda install qgis --channel conda-forge

When I run QGIS using qgis the RVT plugin is loaded correctly and appears in the list of available plugins viewed via the QGIS Python terminal:

for alg in QgsApplication.processingRegistry().algorithms():
        print(alg.id(), "->", alg.displayName())
rvt:rvt_msrm -> RVT Multi-scale relief model

Yet when I initiate PyQGIS from shell python using the following code, the rvt scripts are absent from the processing list.

import sys
from qgis.core import (

QgsApplication.setPrefixPath('~/anaconda3/envs/conda-qgis', True)
qgs = QgsApplication([], False)

# Append the path where processing plugin can be found

import processing
from processing.core.Processing import Processing

for alg in QgsApplication.processingRegistry().algorithms():
        print(alg.id(), "->", alg.displayName())

I've attempted to replicate the internal QGIS python console as far as possible by setting the prefix and plugin paths (QgsApplication.setPrefixPath('~/anaconda3/envs/conda-qgis', True) & sys.path.append('~/anaconda3/envs/conda-qgis/lib/qgis/plugins')) to match those displayed in the General tab of the Log Messages panel when QGIS launches but this hasn't worked.

This answer seems to indicate it might be possible run a python script at the same time qgis is called from the command line using qgis --nologo --code ./python-script.py. Hence, I made a simple model in QGIS that called one of the rvt algorithms and then exported it as a python file. Running this still loads the QGIS GUI and the following errors are output in the Python warnings tab of the Log Messages:

traceback: File "", line 1, in 
              File "~/anaconda3/envs/conda-qgis/share/qgis/python/qgis/utils.py", line 355, in startPlugin
              if not _startPlugin(packageName):
              File "~/anaconda3/envs/conda-qgis/share/qgis/python/qgis/utils.py", line 335, in _startPlugin
              plugins[packageName] = package.classFactory(iface)
              File "~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/rvt-qgis/__init__.py", line 36, in classFactory
              return QRVT(iface)
              File "~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/rvt-qgis/qrvt.py", line 143, in __init__
              self.dlg = QRVTDialog()
              File "~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/rvt-qgis/qrvt_dialog.py", line 44, in __init__
              File "", line 216, in setupUi

So still no joy. I've also tried using the qgis_process utility to call rvt, but the rvt plugins are not listed here either and the plugin itself is not listed as one that can be enabled / disabled using qgis_process plugin enable ...

As far as I can tell the RVT python scripts hosted on pypi.org do not have a linux channel and so cannot be installed into my virtual environment using conda install -c zmigyyy rvt_py

Any advice on how to get this scripts working from the command line? Either via QGIS, PyQGIS or pure python?


I was able to access the plugin algorithms using the following python script saved to file rvtpy.py:

import processing
params = { 
    'INPUT' : '/home/user/eg.tif',
    'OUTPUT' : '/home/user/eg_asvf.tif',
    'ANISOTROPY_DIR' : 315, 
    'ANISOTROPY_LVL' : 0, 
    'FILL_METHOD' : 0, 
    'FILL_NO_DATA' : True, 
    'KEEP_ORIG_NO_DATA' : False, 
    'NOISE_REMOVE' : 0, 
    'NUM_DIRECTIONS' : 16, 
    'RADIUS' : 10,
    'SAVE_AS_8BIT' : False,
    'VE_FACTOR' : 1
feedback = QgsProcessingFeedback()
res = processing.run("rvt:rvt_asvf", params, feedback=feedback)

...and then running the command: qgis --nologo --code ~/rvtpy.py

Though this doesn't actually run the algorithms headlessly, it at least allows me to run them from command line and as part of a scripted workflow.

Your Answer

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

Browse other questions tagged or ask your own question.