<div dir="ltr"><div class="gmail_extra">Hi,<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 4, 2016 at 7:50 PM, Jose M <span dir="ltr"><<a href="mailto:soloninguno@hotmail.com" target="_blank">soloninguno@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>gisbase = r'C:\OSGeo4W\apps\grass\grass-<wbr>7.0.4'<br>
os.environ['GISBASE'] = gisbase<br> </div></blockquote><div><br></div><div>likely unrelated but I suggest to use the way specified in the manual, i.e. obtaining the GISBASE value from the binary:<br><br><pre><span class=""># query GRASS GIS itself for its GISBASE</span>
<span class="">startcmd</span> <span class="">=</span> <span class="">[</span><span class="">grass7bin</span><span class="">,</span> <span class="">'--config'</span><span class="">,</span> <span class="">'path'</span><span class="">]</span>
<span class="">try</span><span class="">:</span>
    <span class="">p</span> <span class="">=</span> <span class="">subprocess</span><span class="">.</span><span class="">Popen</span><span class="">(</span><span class="">startcmd</span><span class="">,</span> <span class="">shell</span><span class="">=</span><span class="">False</span><span class="">,</span>
                         <span class="">stdout</span><span class="">=</span><span class="">subprocess</span><span class="">.</span><span class="">PIPE</span><span class="">,</span> <span class="">stderr</span><span class="">=</span><span class="">subprocess</span><span class="">.</span><span class="">PIPE</span><span class="">)</span>
    <span class="">out</span><span class="">,</span> <span class="">err</span> <span class="">=</span> <span class="">p</span><span class="">.</span><span class="">communicate</span><span class="">()</span>
<span class="">except</span> <span class="">OSError</span> <span class="">as</span> <span class="">error</span><span class="">:</span>
    <span class="">sys</span><span class="">.</span><span class="">exit</span><span class="">(</span><span class="">"ERROR: Cannot find GRASS GIS start script"</span>
             <span class="">" {cmd}: {error}"</span><span class="">.</span><span class="">format</span><span class="">(</span><span class="">cmd</span><span class="">=</span><span class="">startcmd</span><span class="">[</span><span class="">0</span><span class="">],</span> <span class="">error</span><span class="">=</span><span class="">error</span><span class="">))</span>
<span class="">if</span> <span class="">p</span><span class="">.</span><span class="">returncode</span> <span class="">!=</span> <span class="">0</span><span class="">:</span>
    <span class="">sys</span><span class="">.</span><span class="">exit</span><span class="">(</span><span class="">"ERROR: Issues running GRASS GIS start script"</span>
             <span class="">" {cmd}: {error}"</span>
             <span class="">.</span><span class="">format</span><span class="">(</span><span class="">cmd</span><span class="">=</span><span class="">' '</span><span class="">.</span><span class="">join</span><span class="">(</span><span class="">startcmd</span><span class="">),</span> <span class="">error</span><span class="">=</span><span class="">err</span><span class="">))</span>
<span class="">gisbase</span> <span class="">=</span> <span class="">out</span><span class="">.</span><span class="">strip</span><span class="">(</span><span class="">os</span><span class="">.</span><span class="">linesep</span><span class="">)</span></pre><br><a href="https://grass.osgeo.org/grass72/manuals/libpython/script.html#module-script.setup">https://grass.osgeo.org/grass72/manuals/libpython/script.html#module-script.setup</a><br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<br>
gscript.run_command('g.list -m type=raster')<br></div></blockquote><div><br></div><div>Unrelated, but this is not guaranteed to work. Use the syntax:<br><br>
gscript.run_command('g.list', flags='m', type='raster')<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
<br>
<br>
And this is the stacktrace I'm getting<br>
C:\test>setupgrass.py<br>
Traceback (most recent call last):<br>
  File "C:\test\setupgrass.py", line 20, in <module><br>
    gscript.run_command('g.list -m type=raster')<br>
  File "C:\OSGeo4W\apps\grass\grass-<wbr>7.0.4\etc\python\grass\script\<wbr>core.py", line 393, in run_command<br>
    ps = start_command(*args, **kwargs)<br>
  File "C:\OSGeo4W\apps\grass\grass-<wbr>7.0.4\etc\python\grass\script\<wbr>core.py", line 356, in start_command<br>
    if debug_level() > 0:<br>
  File "C:\OSGeo4W\apps\grass\grass-<wbr>7.0.4\etc\python\grass\script\<wbr>core.py", line 1519, in debug_level<br>
    _debug_level = int(gisenv().get('DEBUG', 0))<br>
  File "C:\OSGeo4W\apps\grass\grass-<wbr>7.0.4\etc\python\grass\script\<wbr>core.py", line 935, in gisenv<br>
    s = read_command("g.gisenv", flags='n')<br>
  File "C:\OSGeo4W\apps\grass\grass-<wbr>7.0.4\etc\python\grass\script\<wbr>core.py", line 446, in read_command<br>
    return handle_errors(returncode, stdout, args, kwargs)<br>
  File "C:\OSGeo4W\apps\grass\grass-<wbr>7.0.4\etc\python\grass\script\<wbr>core.py", line 313, in handle_errors<br>
    returncode=returncode)<br>
grass.exceptions.<wbr>CalledModuleError: Module run None ['g.gisenv', '-n'] ended with error<br>
Process ended with non-zero return code -1073741502. See errors in the (error) output.</div></blockquote><div><br><p>According to my Internet search, -1073741502 means STATUS_DLL_INIT_FAILED - DLL Initialization Failed. So perhaps the installation is somehow broken or the paths are not set right. You can try</p><p>print os.environ</p><p>after init() call to see how the paths are set.</p><p>Vaclav<br></p></div></div></div></div>