Hi,
I'm new to grass and I'm having an issue trying to run grass from a python script in my Windows 7 x64 environment. I've read this links https://grasswiki.osgeo.org/wiki/GRASS_and_Python#MS-Windows https://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly https://grass.osgeo.org/grass70/manuals/libpython/script.html#module-script.setup But I'm not getting this working. Here is my python script, running a simple g.list command === import os import sys import subprocess gisbase = r'C:\OSGeo4W\apps\grass\grass-7.0.4' os.environ['GISBASE'] = gisbase grass_pydir = os.path.join(gisbase, "etc", "python") sys.path.append(grass_pydir) import grass.script as gscript import grass.script.setup as gsetup gisdb = os.path.join(os.path.expanduser("~"), "Documents/grassdata") location = "nc_spm_08" mapset = "user1" rcfile = gsetup.init(gisbase, gisdb, location, mapset) # use grass functions here gscript.run_command('g.list -m type=raster') os.remove(rcfile) === And this is the stacktrace I'm getting C:\test>setupgrass.py Traceback (most recent call last): File "C:\test\setupgrass.py", line 20, in <module> gscript.run_command('g.list -m type=raster') File "C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python\grass\script\core.py", line 393, in run_command ps = start_command(*args, **kwargs) File "C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python\grass\script\core.py", line 356, in start_command if debug_level() > 0: File "C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python\grass\script\core.py", line 1519, in debug_level _debug_level = int(gisenv().get('DEBUG', 0)) File "C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python\grass\script\core.py", line 935, in gisenv s = read_command("g.gisenv", flags='n') File "C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python\grass\script\core.py", line 446, in read_command return handle_errors(returncode, stdout, args, kwargs) File "C:\OSGeo4W\apps\grass\grass-7.0.4\etc\python\grass\script\core.py", line 313, in handle_errors returncode=returncode) grass.exceptions.CalledModuleError: Module run None ['g.gisenv', '-n'] ended with error Process ended with non-zero return code -1073741502. See errors in the (error) output. I tried both with Grass standalone installer, and with grass installed through OSGeo4W spackages and I'm getting the same error. Anyone knows what the problem could be? Thanks in advance!
_______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
