Running GRASS Algorithms in QGIS 2.18 on Ubuntu 16.04 – How to Guide

grassqgisqgis-processingUbuntu

I have QGIS and GRASS installed through the UbuntuGIS repositories. If I try to execute any GRASS 6 or 7 algorithm I get the following error message:

"This algorithm cannot be run :-( It seems that GRASS GIS 7 is not correctly installed and configured in your system. Please install it before running GRASS GIS 7 algorithms."

I checked other questions on this issue however most deal with Setup on Windows systems:

On linux I do not have to configure the path of the GRASS folder as the QGIS help on configuring external applications tells me. Grass runs from the shell by typing grass. The Grass-version called by the shell is GRASS 7.2.0 (2016).

Furthermore i checked that GRASS 6 and 7 is activated in the additional providers menu in the toolbox of QGIS.

Any suggestion what could be done to fix this?

Edit

Meanwhile I completly uninstalled and reinstalled qgis python-qgis qgis-plugin-grass from the oficial QGIS repositories…but the error continues.

Edit 2
Checking out the logs for qgis in the Log Messages Panel I found out under the "plugins" tab that the grass plugin does not load properly:

2017-01-23T14:10:22 1   Failed to load /usr/lib/qgis/plugins/libgrassplugin7.so (Reason: Cannot load library /usr/lib/qgis/plugins/libgrassplugin7.so: (libgrass_gis.7.0.3.so: cannot open shared object file: No such file or directory))
2017-01-23T14:10:22 1   Failed to load /usr/lib/qgis/plugins/libgrassprovider7.so (Reason: Cannot load library /usr/lib/qgis/plugins/libgrassprovider7.so: (libgrass_gis.7.0.3.so: cannot open shared object file: No such file or directory))
2017-01-23T14:10:22 1   Failed to load /usr/lib/qgis/plugins/libgrassrasterprovider7.so (Reason: Cannot load library /usr/lib/qgis/plugins/libgrassrasterprovider7.so: (libgrass_gis.7.0.3.so: cannot open shared object file: No such file or directory))

Best Answer

I get the same error with the Ubuntugis version of QGIS and GRASS version 7.2.0.

It seems that 7.2 is not yet correctly adopted in processing. There is already a ticket for it: https://hub.qgis.org/issues/16019 and https://lists.osgeo.org/pipermail/qgis-developer/2017-January/046671.html

As a workaround, you may edit (as sudo) /usr/share/qgis/python/plugins/processing/algs/grass7/Grass7Utils.py line 251 to

            command = 'grass72 ' + Grass7Utils.grassMapsetFolder() \

and line 103 of Grass7AlgorithmProvider.py to

    return 'grass72'

Or downgrade to GRASS 7.0.3 from the main Ubuntu repo.

GRASS 6 commands will not work with GRASS 7, so you can deactivate the 161 GRASS commands.


Just another workaround from the mailing list https://lists.osgeo.org/pipermail/qgis-user/2017-January/038907.html

sudo ln -s /usr/bin/grass72 /usr/bin/grass70


UPDATE

Also reported with http://hub.qgis.org/issues/16110 and fixed with http://hub.qgis.org/projects/quantum-gis/repository/revisions/099e7a77f2c32f469539f542a31df7b0d4b77dd3 That should work for GRASS versions 7.0 up to 7.3

Unfortunately, the fix has not been applied to QGIS 2.18.4, so the workarounds are still necessary.

Related Question