3

I am quite new to QGIS and working with the external applications such as GRASS.

When trying to launch a GRASS tool from the processing toolbox I get the following error:

Missing dependency. This algorithm cannot be run :-(
This algorithm requires GRASS to be run. Unfortunately, it seems that GRASS is not installed in your system, or it is not correctly configured to be used from QGIS Click here to know more about how to install and configure GRASS to be used with QGIS

When I am using GRASS from the Plugins menu it works. I have GRASS 6.4 installed to my system and running, GRASS 7 installed, but it doesn't run, probably due to some known El Capitan issue. Anyhow, GRASS 6.4 should be working. Moreover, there is also the GRASS that comes with the QGIS installation.

Unfortunately I messed up the path to GRASS that was originally set in Processing -> Options before I even tried if the original setup works. I tried really every possible path I could think of, to the GRASS-6.4 installation in my applications folder (/Applications/GRASS-6.4.app) and to the GRASS folder in the QGIS installation (/Applications/QGIS.app/Contents/MacOS/grass), I don't get the GRASS tools to working. I reinstalled QGIS to restore the original settings, but obviously I have to delete the particular settings before (but where?), because the path was still as I set it before reinstallation.

SAGA is working from the processing toolbox.

So, long story short:

  1. Any suggestions what could be the issue? Anyone experiences with running GRASS via processing toolbox with QGIS 2.8 on El Capitan?
  2. It would be already a great help if someone could give me the original path to GRASS set at "Processing" --> "Options"
  • 1
    Not a Mac user but perhaps try going a bit further into your PATH: /Applications/QGIS.app/Contents/MacOS/grass/bin or /Applications/GRASS-6.4.app/Contents/MacOS/bin/? – Joseph Feb 19 '16 at 10:33
3

Why not upgrading your QGIS version?

To know the GRASS path, you need to know how Processing really works.

  • First, it is a Python module (processing) that uses subprocess to execute the original GRASS commands.
  • Consequently, the script need to know the Grass installation path.

With Python in the console, you can obtain the default path (I suppose you use the Kyng Chaos version).

1) For Grass 6.4.x

The script to find the default Grass path is:

/Applications/QGIS.app/Contents/Resources/python/plugins/processing/algs/grass/GrassUtils.py  #lines 256-258 for your QGIS version
import processing
# you want to use here the Grass algoritm 
import  processing.algs.grass.GrassUtils as ga6
ga6.GrassUtils.grassPath()
u'/Applications/QGIS.app/Contents/MacOS/grass'

Therefore, by default, processing uses the GRASS version installed into the QGIS application with the script grass.sh to launch GRASS and execute commands.

import os
os.path.exists(ga6.GrassUtils.grassPath() + os.sep + 'grass.sh')
True

You can let the Processing Options (path to GRASS) empty. QGIS always find the path.

If you want to use another GRASS version (GRASS-6.4.6.app for example), simply change the parameters in the Processing Options with a folder path that contains the grass.sh script (/Applications/GRASS-6.4.6.app/Contents/MacOS for example).

enter image description here

os.path.exists('/Applications/GRASS-6.4.6.app/Contents/MacOS/grass.sh')
True
# and
ga6.GrassUtils.grassPath()
/Applications/GRASS-6.4.6.app/Contents/MacOS
os.path.exists(ga6.GrassUtils.grassPath() + os.sep + 'grass.sh')
True

Result:

enter image description here

2) For Grass 7.x

Same procedure and the file is:

/Applications/QGIS.app/Contents/Resources/python/plugins/processing/algs/grass7/Grass7Utils.py
import processing.algs.grass7.Grass7Utils as ga7
ga7.Grass7Utils.grassPath()
'/Applications/GRASS-7.0.app/Contents/MacOS'
import os 
os.path.exists(ga7.Grass7Utils.grassPath() + os.sep + 'grass70.sh')
False

Problem here, I have a GRASS-7.0.app (from GRASS GIS for Mac) installed but no /Applications/GRASS-7.0.app/Contents/MacOS/grass70.sh script. The script to launch GRASS-7.0.app is /Applications/GRASS-7.0.app/Contents/MacOS/grass.sh

The solution is to replace grass70.sh by grass.sh in the lines 254-256 of the script Grass7Utils.py

Original:

if isMac() and os.path.exists(Grass7Utils.grassPath() + os.sep + 'grass70.sh'):
command = Grass7Utils.grassPath() + os.sep + 'grass70.sh ' \
                + Grass7Utils.grassMapsetFolder() + '/PERMANENT'

Correction:

if isMac() and os.path.exists(Grass7Utils.grassPath() + os.sep + 'grass.sh'):
command = Grass7Utils.grassPath() + os.sep + 'grass.sh ' \
                + Grass7Utils.grassMapsetFolder() + '/PERMANENT'

Result:

enter image description here

Hope this will help you but there are many problems with El Capitan (from GRASS GIS for Mac and Grass Gis 7 does not start in OS X 10.11 El Capitan)

WARNING: current GRASS binaries may not work with EL CAPITAN - OS X 10.11 unless you disable "System Integrity Protection".

  • Thank you so much for the detailed answer. First: I had problems with QGIS 2.10 because there was a bug for raster display, so I downgraded and I am waiting for the new version to be officially confirmed stable before I upgrade again. I should have mentioned that I never worked with python before. I think I managed to run the suggested commands in the python console. I tried the default version and the grass-6.4 but I keep getting the error message. Maybe there is something fundamental I need to setup for running GRASS commands from the processing toolbox that I am not aware of? – FrlBraun Feb 22 '16 at 8:51
  • You have for the moment QGIS 2.8.4.1 (stable version) and QGIS 2.12.1.1, all with GRASS installed into the application and I've never had any problems with GRASS – gene Feb 22 '16 at 16:19

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.