I am struggling to run any GRASS 7.4.1 Session from outside using Python 2.7.15 with Spyder IDLE.

While setting up the GRASS bin and GRASS environment are as follows are all good and showing no problem,

from __future__ import print_function
import os
import sys
import subprocess
# This part works fine
grass7bin = r'C:\GIS\GRASS_741\grass74.bat'
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)

os.environ['GISBASE'] = gisbase
grass_pydir = os.path.join(gisbase, "etc", "python")

# 2. SEtting up the GRASS environment
import grass.script as gscript
import grass.script.setup as gsetup
import grass.script.utils as utils

com_loc = r'F:\PROJECTS\MandurahUFM\Woking_HT\MandurahUFM'

# Getting the environmental variables
gisdb = os.path.join(com_loc) #os.path.expanduser("~"),
location = "vht_grs"
mapset = "CoM_supplied"
rcfile = gsetup.init(gisbase, gisdb, location, mapset)
# Routine Checks
print (gscript.read_command('g.gisenv'))

But I'm getting the following DLL errors when try to run any main modules (eg. print (gscript.read_command('g.region', flags='p')) from GRASS.

enter image description here


enter image description here

In addition to the above 2 entry point error, also getting this in the console:

CalledModuleError: Module run None ['g.proj', '-p'] ended with error
Process ended with non-zero return code -1073741511. See errors in the (error) output.

My system used to run all my python scripts nice and smooth with GRASS but could not run it after got a new Windows 10 system and installed all the required software (Anaconda 2 with Python 2.15.7, GRASS 7.4.1, QGIS 3.2 etc)

I have tried reinstalling standalone GRASS, from OSGeo4W, Anaconda and its dependent packages, trying everything it says on the GRASS Wiki error page. Nothing is fixing it.

I solved a similar issue by myself at Entry point not found Error initiating GRASS GIS from Python, but this time I am unable to!

  • It looks like a DLL confusion, i.e. the sqlite.dll (not sure about the correct name) exists twice or several times on the system but not as identical version. Please check that (when installing via OSGeo4W this problem should be avoided). – markusN Oct 14 '18 at 10:38

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.