45

I updated QGIS to version 3.6 using OSGEO4w

When I try to run any GRASS script, I get the following error message :

Error message

This algorithm cannot be run :-( The specified GRASS 7 folder "C:\OSGEO4~1\bin\bin" does not contain a valid set of GRASS 7 modules. Please, go to the Processing settings dialog, and check that the GRASS 7 folder is correctly configured

It looks like the path doesn't exist, but I couldn't find a place to change it; it is not an option in the processing settings any more like in versions 2.x.

Is there a way to run those processing scripts in QGIS 3.6 and if so, how could I tweak the settings needed?


Here is what my processing options looks like

Processing parameters

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Kantan
  • 1,917
  • 2
  • 14
  • 26

9 Answers9

66

If I open QGIS with the shortcut "QGIS Desktop 3.6.0 with GRASS 7.6.0" everything works fine. If I open QGIS with the shortcut "QGIS Desktop 3.6.0" I get the same error as you.

UPDATE for QGIS 3.20: Please use qgis.bat located in C:\OSGeo4W\bin as qgis-bin-g7.exe is missing in the latest version.

Comrade Che
  • 7,091
  • 27
  • 58
Dataform
  • 1,346
  • 8
  • 5
  • 13
    I wonder why GRASS is not the default option for starting with QGIS. – Comrade Che Sep 20 '19 at 10:29
  • The exact same problem arose again and was resolved by updating the grass package with OSGEO4w. – Comrade Che Dec 16 '19 at 06:07
  • I do not get the QGIS Desktop x.x.x with GRASS x.x.x option at all. I only get the QGIS Desktop option. What could be wrong? – Nancy Dec 23 '19 at 09:13
  • 1
    If like me you don't have that shortcut, you can create a new one pointing at "qgis-bin-g7.exe" in the same folder as the QGIS applications for which you already have a shortcut. In my case, the folder is C:\OSGeo4W64\bin. This will open GRASS with your current latest version of QGIS. I use QGIS 3.4 (current long-term release), and so I've changed the shortcut to point to "qgis-ltr-bin-g7". – blackthorn Jan 07 '20 at 17:01
  • For me, i don't have such a shortcut. And it definitely depends on the environment. So I added the line call "%OSGEO4W_ROOT%\apps\grass\grass78\etc\env.bat" to my qgis batch file, and grass tools work. Of cource the path must be correct and the line should come after that line call "%~dp0\o4w_env.bat" – Andreas Müller Jan 09 '20 at 14:50
  • I opened the properties of a .qgz of mine and changed the app to execute from qgis.bat to qgis-grass7.bat. Seems to work fine. Now my QGIS project files don't have a nice icon any more, but, well, you know, meh... I'll take care of it when I have time for aesthetics. – thymaro Apr 27 '20 at 16:26
  • Standalone solution: https://gis.stackexchange.com/a/366866/35561 – Comrade Che Jul 05 '20 at 11:30
  • Using the option to open QGIS with GRASS worked for me. – Stonetip Dec 21 '20 at 17:24
8

I had the same problem but I managed to solve it by renaming my grass folder from "grass76" to grass-7.6.0".

Friedemann
  • 101
  • 3
  • this will be because the folder path that the bat file is pointing to is still the old one. This still seems to be an issue in later versions, where the OSGEO installer upgrades Grass, but the bat file still points to older grass folder version. You can change either, the folder, or the bat file. – nr_aus Dec 01 '22 at 08:27
6

Go to C:\Program Files\QGIS 3.12\apps\grass\grass78\ and copy the "bin" folder directly into C:\Program Files\QGIS 3.12\bin\.

Now the GRASS modules are in the specified path C:\Program Files\QGIS 3.12\bin\bin. Done

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
Steffen
  • 61
  • 1
  • 1
5

Based on this grasswiki-article setting the operating system environment variable GISBASE to the GRASS installation folder might fix the issue (e.g. C:\OSGeo4W\apps\grass\grass76).

QGIS 3.8 processing options still doesn't contain an option for the GRASS folder.

I refer to Windows operating system and QGIS 3.8 / GRASS 7.6.

Nicolo
  • 340
  • 3
  • 7
  • nailed it on the head for me: no GRASS folder in processing options for QGIS 3.8. There are a few other GRASS-associated folders, but nothing that is distinctly GRASS. I'm using QGIS 3.8.1. With respect to Taras' suggestion that the OP did not launch "QGIS with GRASS", that is not an option for me currently on my machine and may not have been one for the OP either. I know I've had that option in the past, I don't know what I did differently when I installed QGIS on this new (for me) machine to miss it. Adding the new environment path worked for me it seems. – shea Oct 17 '19 at 17:22
  • Fixed it for me! – foobarbecue Nov 09 '19 at 17:36
  • With QGIS 3.14 for Windows my answer above isn't valid anymore. But setting the path within qgis-bin.env file in QGIS bin folder solves the issue. The QGIS settings dialog still doesn't contain this setting. – Nicolo Oct 01 '20 at 07:32
5

To me, it seems like some environment variables are missing when starting the "normal" qgis. I fixed this in QGIS 3.4.13 by changing qgis-ltr-bin.env and qgis-ltr.bat . In the 3.6, 3.8 (...) version these two files will have a different but similar name. If you

right click on your qgis start icon > open file path

this should lead you to ...\OSGeo4W64\bin or wherever you have installed qgis. You´ll find the two files there. Open them with a standard text editor (e.g. notepad) to make changes:

qgis-ltr-bin.env:

  • change PATH to the same PATH-line that is saved in qgis-ltr-bin-g7.env (located in the same folder)
  • from qgis-ltr-bin-g7.env add the variables GISBASE,GRASS_PROJSHARE and GRASS_PYTHON

in qgis-ltr.bat:

  • add line 3 from qgis-ltr-grass7.bat (located in the same folder): call "%OSGEO4W_ROOT%\apps\grass\grass78\etc\env.bat" (maybe the grass folder has a different name in your version)
  • change PATH to the same PATH-line that is saved in qgis-ltr-grass7.bat (line 7)
4

In respect to a part of your question

"It looks like the path doesn't exist, but I couldn't find a place to change it; it is not an option in the processing settings any more like in versions 2.x."

you can manage the path of the working GRASS folder through

Settings > Options > Processing > Providers > GRASS

Based on QGIS 3.0.3 version

GRASS_setting_window

where you can adjust the 'GRASS7 folder', just double click on it.

And by the way, GRASS works fine on my QGIS 3.0.3 version.

Taras
  • 32,823
  • 4
  • 66
  • 137
2

The simple folder name change fix allowed the grass toolbox functions to open in QGIS 3.10. However, when executed, GRASS operations all failed with the following error in the log:

The system cannot find the path specified. '""' is not recognized as an internal or external command, operable program or batch file.

I tried setting the Windows environmental variable (using the GRASS folder name reverted back to 'grass78'), as described in another answer, and the GRASS operations now execute properly in QGIS. This seems to be the proper solution.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
ewolf
  • 21
  • 4
  • Thanks for your input, could you point me to a resource to know which variable to set and where? – Kantan Nov 26 '19 at 06:59
  • 3
    I use Windows 10, so in Windows Explorer: right click This PC, select Properties then Advanced system settings, then Advanced tab, then Environmental Variables. Click New... and enter "GISBASE" in Variable Name, and "C:\OSGeo4W64\apps\grass\grass78" in Variable Value [NOTE: your path may be different depending on the version of QGIS and/or GRASS you have]. Click OK and you should see the newly created variable added to the list. – ewolf Nov 26 '19 at 20:52
1

Usually, this message appears when Qgis is open with the option "Qgis Desktop 3.X", using this interface Qgis is charged without GRASS Library. So, when someone tries to use a GRASS tool, Qgis doesn't find the GRASS library.

To use GRASS tools it is necessary to open Qgis using "Qgis Desktop 3.X with GRASS 7"

0

Another solution to use GRASS in processing ToolBox (with QGIS) is to find in C:\OSGeo4W64\apps\qgis\python\processing\algs\grass7\ the file Grass7Utils.py and to replace the terms:

  • grass-7. by grass7 in the code located at line 223 or thereabouts
  • then for version in ['', '7', '76', '74', '72', '71', '70']:" by for version in ['', '7', '78', '76', '74', '72', '71', '70']: in the code located at line 229 or thereabouts.
gHupf
  • 1,151
  • 8
  • 32