<div dir="ltr">Hello,<br><br>How do I run scripts located in C:\Program Files (x86)\GRASS GIS 7.0.0\scripts?<br><br>I am learning GRASS 7.0.0 on Windows 7 by converting some GRASS 6.4 shell scripts to GRASS 7 Python scripts (import grass.script as grass) and GRASS 7 PyGRASS scripts (from grass.pygrass.modules import Module).<br><br>My installation is working fine. I can manually run the commands (from a shell script) in the "Command console" window of the "Layer Manager". For example, I can enter "g.region swwake_30m -p" in the "Command prompt" area and get the following results:<br><br><br>Sun Mar 01 12:32:30 2015)                                                      <br>g.region swwake_30m -p                                                          <br>projection: 99 (Lambert Conformal Conic)<br>zone:       0<br>datum:      nad83<br>ellipsoid:  a=6378137 es=0.006694380022900787<br>north:      228500<br>south:      215000<br>west:       630000<br>east:       645000<br>nsres:      30<br>ewres:      30<br>rows:       450<br>cols:       500<br>cells:      225000<br>(Sun Mar 01 12:32:31 2015) Command finished (0 sec)                             <br><br>I am using the "Pythonwin" IDE to develop the scripts (C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\Pythonwin.exe). In the "GRASS GIS 7.0.0 GUI" Command Prompt window I type "pythonwin" and the IDE starts up.<br><br>I have spent several days trying to understand how to create GRASS Python scripts and GRASS PyGRASS scripts from the online documentation(<a href="http://grasswiki.osgeo.org/wiki/GRASS_and_Python">http://grasswiki.osgeo.org/wiki/GRASS_and_Python</a>) and by studying the script samples (C:\Program Files (x86)\GRASS GIS 7.0.0\scripts). I have not been successful in getting example code to run but I am still working through the documentation.<br><br>But, I should be able to run scripts located in C:\Program Files (x86)\GRASS GIS 7.0.0\scripts.<br><br>Correct?<br><br>1. If I open .\scripts\<a href="http://d.what.rast.py">d.what.rast.py</a> in the Pythonwin IDE and try to run it, I get this output:<br><br>OSError error(9): The handle is invalid<br>Traceback (most recent call last):<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript<br>    exec codeObject in __main__.__dict__<br>  File "C:\Users\Rob\Documents\grassscripts\pygrass\make_raster_using_mapcalc.py", line 8, in <module><br>    g.message("Filter elevation map by a threshold...")<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\pygrass\modules\shortcuts.py", line 46, in __getattr__<br>    return self.cls('%s.%s' % (self.prefix, name.replace('_', '.')))<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\pygrass\modules\interface\module.py", line 498, in __init__<br>    raise GrassError(str_err % <a href="http://self.name">self.name</a>)<br>GrassError: Error running: `g.message --interface-description`.<br>Traceback (most recent call last):<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript<br>    exec codeObject in __main__.__dict__<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\<a href="http://d.what.rast.py">d.what.rast.py</a>", line 45, in <module><br>    main()<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\<a href="http://d.what.rast.py">d.what.rast.py</a>", line 30, in main<br>    options, flags = gcore.parser()<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\script\core.py", line 680, in parser<br>    p = subprocess.Popen([prog, '-n'] + argv, stdout=subprocess.PIPE)<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 703, in __init__<br>    errread, errwrite) = self._get_handles(stdin, stdout, stderr)<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 839, in _get_handles<br>    p2cread = self._make_inheritable(p2cread)<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 878, in _make_inheritable<br>    _subprocess.DUPLICATE_SAME_ACCESS)<br>WindowsError: [Error 6] The handle is invalid<br>Traceback (most recent call last):<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript<br>    exec codeObject in __main__.__dict__<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\<a href="http://d.what.rast.py">d.what.rast.py</a>", line 45, in <module><br>    main()<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\<a href="http://d.what.rast.py">d.what.rast.py</a>", line 30, in main<br>    options, flags = gcore.parser()<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\script\core.py", line 680, in parser<br>    p = subprocess.Popen([prog, '-n'] + argv, stdout=subprocess.PIPE)<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 703, in __init__<br>    errread, errwrite) = self._get_handles(stdin, stdout, stderr)<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 839, in _get_handles<br>    p2cread = self._make_inheritable(p2cread)<br>  File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 878, in _make_inheritable<br>    _subprocess.DUPLICATE_SAME_ACCESS)<br>WindowsError: [Error 6] The handle is invalid<br>>>> <br> <br>2. If I go to the "Python shell" tab on the "Layer Manager" and do File -> Launch Script and browse to .\scripts\<a href="http://d.what.rast.py">d.what.rast.py</a>, I get this output:<br><br>(Sun Mar 01 12:32:31 2015) Command finished (0 sec)                             <br>Launching script 'C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\<a href="http://d.what.rast.py">d.what.rast.py</a>'...<br>Traceback (most recent call last):<br>  File "C:\Program Files (x86)\GRASS GIS<br>7.0.0\gui\wxpython\gui_core\forms.py", line 718, in OnRun<br><br>gcmd.Command(cmd)<br>  File "C:\Program Files (x86)\GRASS GIS<br>7.0.0\gui\wxpython\core\gcmd.py", line 397, in __init__<br><br>_("Error: ") + self.__GetError()))<br>core.gcmd<br>.<br>GException<br>:<br>Execution failed: 'd.what.rast map=elevation'<br>Details:<br>Error:<br><br>Any ideas on what might be going on here?<br><br>Rob Parsons<br>Raleigh NC<br><br></div>