Hello, How do I run scripts located in C:\Program Files (x86)\GRASS GIS 7.0.0\scripts?
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). 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: Sun Mar 01 12:32:30 2015) g.region swwake_30m -p projection: 99 (Lambert Conformal Conic) zone: 0 datum: nad83 ellipsoid: a=6378137 es=0.006694380022900787 north: 228500 south: 215000 west: 630000 east: 645000 nsres: 30 ewres: 30 rows: 450 cols: 500 cells: 225000 (Sun Mar 01 12:32:31 2015) Command finished (0 sec) 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. I have spent several days trying to understand how to create GRASS Python scripts and GRASS PyGRASS scripts from the online documentation( http://grasswiki.osgeo.org/wiki/GRASS_and_Python) 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. But, I should be able to run scripts located in C:\Program Files (x86)\GRASS GIS 7.0.0\scripts. Correct? 1. If I open .\scripts\d.what.rast.py in the Pythonwin IDE and try to run it, I get this output: OSError error(9): The handle is invalid Traceback (most recent call last): File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript exec codeObject in __main__.__dict__ File "C:\Users\Rob\Documents\grassscripts\pygrass\make_raster_using_mapcalc.py", line 8, in <module> g.message("Filter elevation map by a threshold...") File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\pygrass\modules\shortcuts.py", line 46, in __getattr__ return self.cls('%s.%s' % (self.prefix, name.replace('_', '.'))) File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\pygrass\modules\interface\module.py", line 498, in __init__ raise GrassError(str_err % self.name) GrassError: Error running: `g.message --interface-description`. Traceback (most recent call last): File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript exec codeObject in __main__.__dict__ File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\d.what.rast.py", line 45, in <module> main() File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\d.what.rast.py", line 30, in main options, flags = gcore.parser() File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\script\core.py", line 680, in parser p = subprocess.Popen([prog, '-n'] + argv, stdout=subprocess.PIPE) File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 703, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 839, in _get_handles p2cread = self._make_inheritable(p2cread) File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 878, in _make_inheritable _subprocess.DUPLICATE_SAME_ACCESS) WindowsError: [Error 6] The handle is invalid Traceback (most recent call last): File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript exec codeObject in __main__.__dict__ File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\d.what.rast.py", line 45, in <module> main() File "C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\d.what.rast.py", line 30, in main options, flags = gcore.parser() File "C:\Program Files (x86)\GRASS GIS 7.0.0\etc\python\grass\script\core.py", line 680, in parser p = subprocess.Popen([prog, '-n'] + argv, stdout=subprocess.PIPE) File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 703, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 839, in _get_handles p2cread = self._make_inheritable(p2cread) File "C:\Program Files (x86)\GRASS GIS 7.0.0\Python27\lib\subprocess.py", line 878, in _make_inheritable _subprocess.DUPLICATE_SAME_ACCESS) WindowsError: [Error 6] The handle is invalid >>> 2. If I go to the "Python shell" tab on the "Layer Manager" and do File -> Launch Script and browse to .\scripts\d.what.rast.py, I get this output: (Sun Mar 01 12:32:31 2015) Command finished (0 sec) Launching script 'C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\ d.what.rast.py'... Traceback (most recent call last): File "C:\Program Files (x86)\GRASS GIS 7.0.0\gui\wxpython\gui_core\forms.py", line 718, in OnRun gcmd.Command(cmd) File "C:\Program Files (x86)\GRASS GIS 7.0.0\gui\wxpython\core\gcmd.py", line 397, in __init__ _("Error: ") + self.__GetError())) core.gcmd . GException : Execution failed: 'd.what.rast map=elevation' Details: Error: Any ideas on what might be going on here? Rob Parsons Raleigh NC
_______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
