I want to try out the pygrass API and I dont want to use GRASS cli. I would like to write a python script, import the pygrass and play around with common algorithms eg distance, buffer etc. On my Linux mint 18.3 machine, I have python 3.6 and I have also installed GRASS 7.8. Testing them on command line works, however I get an error when I run the Python script:

algone@gst-node3:~/airflow/plugins$ /home/algone/.local/bin/grass --config path 2019-09-18 16:20:55 gst-node3 root[30417] CRITICAL Junto library not added to PATH. Install junto.

I have googled the error message

2019-09-18 16:20:55 gst-node3 root[30417] CRITICAL Junto library not added to PATH. Install junto. but did not find anything relevant. I am wondering if this is a GRASS, PyGRASS or Python issue.

Here is the python script:

import os
import sys
import subprocess

# define GRASS Database
# add your path to grassdata (GRASS GIS database) directory
gisdb = os.path.join(os.path.expanduser("~"), "grassdata")
# the following path is the default path on MS Windows
# gisdb = os.path.join(os.path.expanduser("~"), "Documents/grassdata")

# specify (existing) Location and Mapset
location = "grassdata"
mapset = "PERMANENT"
# path to the GRASS GIS launch script
# we assume that the GRASS GIS start script is available and on PATH
# query GRASS itself for its GISBASE
# (with fixes for specific platforms)
# needs to be edited by the user
grass7bin = 'grass'
if sys.platform.startswith('win'):
    # MS Windows
    grass7bin = r'C:\OSGeo4Win\grass77.bat'
    # uncomment when using standalone WinGRASS installer
    # grass7bin = r'C:\Program Files (x86)\GRASS GIS 7.2.0\grass77.bat'
    # this can be avoided if GRASS executable is added to PATH
elif sys.platform == 'linux':

    # Just in case the right grass instance is not being executed
    grass7bin = '/home/algone/.local/bin/grass'

# query GRASS GIS itself for its GISBASE
startcmd = [grass7bin, '--config', 'path']
    p = subprocess.Popen(startcmd, shell=False,
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = p.communicate()
except OSError as error:
    sys.exit("ERROR: Cannot find GRASS GIS start script"
             " {cmd}: {error}".format(cmd=startcmd[0], error=error))
if p.returncode != 0:
    sys.exit("ERROR: Issues running GRASS GIS start script"
             " {cmd}: {error}"
             .format(cmd=' '.join(startcmd), error=err))
gisbase = out.strip(os.linesep)

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.