1

I am trying to access GRASS from Python (Spyder).

I have:

Code:

import os

grass78 --config

C:/Program Files/QGIS 3.22.7/apps/grass/grass78

possible GRASSBIN

C:\Program Files\QGIS 3.22.7\apps\grass\grass78\bin

set some common environmental variables, like:

os.environ.update(dict(GRASSBIN = r"C:\Program Files\QGIS 3.22.7\apps\grass\grass78\bin")) grass7bin_win = r'C:\Program Files\QGIS 3.22.7\bin\grass78.bat'

from grass_session import Session from grass.pygrass.modules.shortcuts import general as g

errors:

RuntimeError: Cannot find GRASS GIS start script: C:\Program Files\QGIS 3.22.7\apps\grass\grass78\bin, set the right one using the GRASSBIN environm. variable

ModuleNotFoundError: No module named 'grass'

I think this is similar to How to use GRASS GIS in Python standalone? and Finding GRASSBIN on Linux but they're from standalone GRASS installations and I can't work it out still.

Any ideas on how to fix this?

william3031
  • 371
  • 2
  • 12

0 Answers0