<div dir="ltr"><div><br>Thanks for the help. <br><br>I do not have a use case. I am learning GRASS 7.0, on Windows 7 platform, by going through all the online documentation, Python script examples, and PyGRASS examples. I will eventually get into the source code.<br><br></div><div>I hope it is OK to use this forum for learning help?<br></div><div><br></div><div>Rob Parsons<br></div><div>Raleigh NC<br><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 6, 2015 at 9:46 PM, Anna Petrášová <span dir="ltr"><<a href="mailto:kratochanna@gmail.com" target="_blank">kratochanna@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Fri, Mar 6, 2015 at 8:45 PM, Rob Parsons <span dir="ltr"><<a href="mailto:jrobparsons@gmail.com" target="_blank">jrobparsons@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>I converted the interactive script at the top of this page,<br><br><a href="http://grass.osgeo.org/grass70/manuals/libpython/script.html" target="_blank">http://grass.osgeo.org/grass70/manuals/libpython/script.html</a><br><br>to a batch script.<br><br></div><div>I understand what the script is trying to do. When I File -> "Launch script" from the "Layer Manager" GUI, the script appears to run to completion, but, this message is displayed on the "Command console":<br><br> "ERROR: Unable to create file <C:\grassdata/North_Carolina/user1/.tmp/unknown/4808.1>"<br><br></div><div>I have traced it to this statement in the script:<br><br>map2d_2.read("map2d_1")<br><br></div><div>The file was indeed created.<br><br>C:\grassdata\North_Carolina\user1\.tmp\unknown>dir<br> Volume in drive C is OS<br> Volume Serial Number is C4D0-A091<br><br> Directory of C:\grassdata\North_Carolina\user1\.tmp\unknown<br><br>2015-03-06  08:25 PM    <DIR>          .<br>2015-03-06  08:25 PM    <DIR>          ..<br>2015-03-06  08:25 PM               192 4808.0<br>2015-03-06  08:25 PM               192 4808.1<br>2015-03-06  08:25 PM               576 4808.2<br>               3 File(s)            960 bytes<br>               2 Dir(s)  22,857,420,800 bytes free<br><br>C:\grassdata\North_Carolina\user1\.tmp\unknown><br><br></div><div>The script prints out the 2D and 3D arrays.<br><br></div><div>The 2D rasters (map2d_1 and map2d_2) are written to the 'user1' mapset but not the 3D rasters (map3d_1 and map3d_2).<br><br></div><div>Has anyone successfully run this example?</div></div></blockquote><div><br></div></span><div>It seems it got broken very recently, I created a ticket for that (<a href="http://trac.osgeo.org/grass/ticket/2616" target="_blank">http://trac.osgeo.org/grass/ticket/2616</a>). Do you need to use this library? There is also newer library PyGRASS (<a href="http://grass.osgeo.org/grass70/manuals/libpython/pygrass_raster.html" target="_blank">http://grass.osgeo.org/grass70/manuals/libpython/pygrass_raster.html</a>), it has more capabilities, so you might want to use that anyway. Perhaps if you would share what is your usecase, people may have some advice.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Anna</div></font></span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><span><font color="#888888"><br><br></font></span></div><span><font color="#888888"><div>Rob Parsons<br></div><div>Raleigh NC<br><br></div><div><br></div><div><br></div><div><br></div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 5, 2015 at 10:42 PM, Rob Parsons <span dir="ltr"><<a href="mailto:jrobparsons@gmail.com" target="_blank">jrobparsons@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Yes. <br>I do get the "add the script path to GRASS_ADDON_PATH" prompt. After I say 'yes' to the prompt, the script runs successfully.<br></div>Thanks!<br><br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 5, 2015 at 1:14 PM,  <span dir="ltr"><<a href="mailto:grass-user-request@lists.osgeo.org" target="_blank">grass-user-request@lists.osgeo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Send grass-user mailing list submissions to<br>
        <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:grass-user-request@lists.osgeo.org" target="_blank">grass-user-request@lists.osgeo.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:grass-user-owner@lists.osgeo.org" target="_blank">grass-user-owner@lists.osgeo.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of grass-user digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Re: grass-user Digest, Vol 107, Issue 2 (Anna Petr??ov?)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 5 Mar 2015 13:14:05 -0500<br>
From: Anna Petr??ov? <<a href="mailto:kratochanna@gmail.com" target="_blank">kratochanna@gmail.com</a>><br>
To: Rob Parsons <<a href="mailto:jrobparsons@gmail.com" target="_blank">jrobparsons@gmail.com</a>><br>
Cc: GRASS user list <<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>><br>
Subject: Re: [GRASS-user] grass-user Digest, Vol 107, Issue 2<br>
Message-ID:<br>
        <CAE0EDEro0wnTAaLkgmwsvpZcUckXvXmzBUMcOv4J5qwW=<a href="mailto:qRZPg@mail.gmail.com" target="_blank">qRZPg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
On Wed, Mar 4, 2015 at 10:09 PM, Rob Parsons <<a href="mailto:jrobparsons@gmail.com" target="_blank">jrobparsons@gmail.com</a>> wrote:<br>
<br>
> Thanks for the direction!<br>
><br>
> I have successfully worked through the examples on<br>
> <a href="http://grass.osgeo.org/grass70/manuals/libpython/script_intro.html" target="_blank">http://grass.osgeo.org/grass70/manuals/libpython/script_intro.html</a> except<br>
> for the last one about adding a module interface to a script. I copied the<br>
> code into a python file named module_interface.py. After I File-> "Launch<br>
> script" and select module_interface.py, the module GUI pops up and prompts<br>
> for the raster inputs and output. But, after clicking on "Run", the script<br>
> reports the following message:<br>
><br>
><br>
Before the module dialog opens, you should get a dialog asking to add the<br>
script path to GRASS_ADDON_PATH. If you do it, you should be able to run<br>
the script. Did you get this dialog?<br>
<br>
Anna<br>
<br>
(Wed Mar 04 21:55:29<br>
> 2015)<br>
> module_interface araster=el_D782_6m@PERMANENT braster=el_D783_6m@PERMANENT<br>
> output=el_r_6m<br>
> 'module_interface' is not recognized as an internal or<br>
> external command,<br>
> operable program or batch file.<br>
> (Wed Mar 04 21:55:29 2015) Command finished (0<br>
> sec)<br>
><br>
> Anyone seen this message?<br>
><br>
> Rob Parsons<br>
> Raleigh NC<br>
><br>
><br>
><br>
> On Sun, Mar 1, 2015 at 8:13 PM, <<a href="mailto:grass-user-request@lists.osgeo.org" target="_blank">grass-user-request@lists.osgeo.org</a>><br>
> wrote:<br>
><br>
>> Send grass-user mailing list submissions to<br>
>>         <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
>><br>
>> To subscribe or unsubscribe via the World Wide Web, visit<br>
>>         <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
>> or, via email, send a message with subject or body 'help' to<br>
>>         <a href="mailto:grass-user-request@lists.osgeo.org" target="_blank">grass-user-request@lists.osgeo.org</a><br>
>><br>
>> You can reach the person managing the list at<br>
>>         <a href="mailto:grass-user-owner@lists.osgeo.org" target="_blank">grass-user-owner@lists.osgeo.org</a><br>
>><br>
>> When replying, please edit your Subject line so it is more specific<br>
>> than "Re: Contents of grass-user digest..."<br>
>><br>
>><br>
>> Today's Topics:<br>
>><br>
>>    1. GRASS 7.0 Running Scripts (.\GRASS GIS 7.0.0\scripts)<br>
>>       (Rob Parsons)<br>
>>    2. Re: GRASS 7.0 Running Scripts (.\GRASS GIS        7.0.0\scripts)<br>
>>       (Vaclav Petras)<br>
>><br>
>><br>
>> ----------------------------------------------------------------------<br>
>><br>
>> Message: 1<br>
>> Date: Sun, 1 Mar 2015 19:37:59 -0500<br>
>> From: Rob Parsons <<a href="mailto:jrobparsons@gmail.com" target="_blank">jrobparsons@gmail.com</a>><br>
>> To: <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
>> Subject: [GRASS-user] GRASS 7.0 Running Scripts (.\GRASS GIS<br>
>>         7.0.0\scripts)<br>
>> Message-ID:<br>
>>         <<br>
>> <a href="mailto:CAFvPsPBH1xVpEgff15hxknY0qeeMUeehP9bucV4FB9ZgQ_2%2Bcg@mail.gmail.com" target="_blank">CAFvPsPBH1xVpEgff15hxknY0qeeMUeehP9bucV4FB9ZgQ_2+cg@mail.gmail.com</a>><br>
>> Content-Type: text/plain; charset="utf-8"<br>
>><br>
>> Hello,<br>
>><br>
>> How do I run scripts located in C:\Program Files (x86)\GRASS GIS<br>
>> 7.0.0\scripts?<br>
>><br>
>> I am learning GRASS 7.0.0 on Windows 7 by converting some GRASS 6.4 shell<br>
>> scripts to GRASS 7 Python scripts (import grass.script as grass) and GRASS<br>
>> 7 PyGRASS scripts (from grass.pygrass.modules import Module).<br>
>><br>
>> My installation is working fine. I can manually run the commands (from a<br>
>> shell script) in the "Command console" window of the "Layer Manager". For<br>
>> example, I can enter "g.region swwake_30m -p" in the "Command prompt" area<br>
>> and get the following results:<br>
>><br>
>><br>
>> Sun Mar 01 12:32:30<br>
>> 2015)<br>
>> g.region swwake_30m<br>
>> -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<br>
>> sec)<br>
>><br>
>> I am using the "Pythonwin" IDE to develop the scripts (C:\Program Files<br>
>> (x86)\GRASS GIS 7.0.0\Python27\lib\site-packages\pythonwin\Pythonwin.exe).<br>
>> In the "GRASS GIS 7.0.0 GUI" Command Prompt window I type "pythonwin" and<br>
>> the IDE starts up.<br>
>><br>
>> I have spent several days trying to understand how to create GRASS Python<br>
>> scripts and GRASS PyGRASS scripts from the online documentation(<br>
>> <a href="http://grasswiki.osgeo.org/wiki/GRASS_and_Python" target="_blank">http://grasswiki.osgeo.org/wiki/GRASS_and_Python</a>) and by studying the<br>
>> script samples (C:\Program Files (x86)\GRASS GIS 7.0.0\scripts). I have<br>
>> not<br>
>> been successful in getting example code to run but I am still working<br>
>> through the documentation.<br>
>><br>
>> But, I should be able to run scripts located in C:\Program Files<br>
>> (x86)\GRASS GIS 7.0.0\scripts.<br>
>><br>
>> Correct?<br>
>><br>
>> 1. If I open .\scripts\<a href="http://d.what.rast.py" target="_blank">d.what.rast.py</a> in the Pythonwin IDE and try to run<br>
>> 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<br>
>><br>
>> 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py",<br>
>> line 325, in RunScript<br>
>>     exec codeObject in __main__.__dict__<br>
>>   File<br>
>><br>
>> "C:\Users\Rob\Documents\grassscripts\pygrass\make_raster_using_mapcalc.py",<br>
>> line 8, in <module><br>
>>     g.message("Filter elevation map by a threshold...")<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 7.0.0\etc\python\grass\pygrass\modules\shortcuts.py", line 46, in<br>
>> __getattr__<br>
>>     return self.cls('%s.%s' % (self.prefix, name.replace('_', '.')))<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 7.0.0\etc\python\grass\pygrass\modules\interface\module.py", line 498, in<br>
>> __init__<br>
>>     raise GrassError(str_err % <a href="http://self.name" target="_blank">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<br>
>><br>
>> 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py",<br>
>> 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" target="_blank">d.what.rast.py</a>",<br>
>> 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" target="_blank">d.what.rast.py</a>",<br>
>> line 30, in main<br>
>>     options, flags = gcore.parser()<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 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<br>
>> 7.0.0\Python27\lib\subprocess.py",<br>
>> line 703, in __init__<br>
>>     errread, errwrite) = self._get_handles(stdin, stdout, stderr)<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 7.0.0\Python27\lib\subprocess.py",<br>
>> line 839, in _get_handles<br>
>>     p2cread = self._make_inheritable(p2cread)<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 7.0.0\Python27\lib\subprocess.py",<br>
>> 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<br>
>><br>
>> 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py",<br>
>> 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" target="_blank">d.what.rast.py</a>",<br>
>> 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" target="_blank">d.what.rast.py</a>",<br>
>> line 30, in main<br>
>>     options, flags = gcore.parser()<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 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<br>
>> 7.0.0\Python27\lib\subprocess.py",<br>
>> line 703, in __init__<br>
>>     errread, errwrite) = self._get_handles(stdin, stdout, stderr)<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 7.0.0\Python27\lib\subprocess.py",<br>
>> line 839, in _get_handles<br>
>>     p2cread = self._make_inheritable(p2cread)<br>
>>   File "C:\Program Files (x86)\GRASS GIS<br>
>> 7.0.0\Python27\lib\subprocess.py",<br>
>> 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 -><br>
>> Launch Script and browse to .\scripts\<a href="http://d.what.rast.py" target="_blank">d.what.rast.py</a>, I get this output:<br>
>><br>
>> (Sun Mar 01 12:32:31 2015) Command finished (0<br>
>> sec)<br>
>> Launching script 'C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\<br>
>> <a href="http://d.what.rast.py" target="_blank">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>
>> -------------- next part --------------<br>
>> An HTML attachment was scrubbed...<br>
>> URL: <<br>
>> <a href="http://lists.osgeo.org/pipermail/grass-user/attachments/20150301/b41b2959/attachment-0001.html" target="_blank">http://lists.osgeo.org/pipermail/grass-user/attachments/20150301/b41b2959/attachment-0001.html</a><br>
>> ><br>
>><br>
>> ------------------------------<br>
>><br>
>> Message: 2<br>
>> Date: Sun, 1 Mar 2015 20:12:57 -0500<br>
>> From: Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com" target="_blank">wenzeslaus@gmail.com</a>><br>
>> To: Rob Parsons <<a href="mailto:jrobparsons@gmail.com" target="_blank">jrobparsons@gmail.com</a>><br>
>> Cc: GRASS user list <<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>><br>
>> Subject: Re: [GRASS-user] GRASS 7.0 Running Scripts (.\GRASS GIS<br>
>>         7.0.0\scripts)<br>
>> Message-ID:<br>
>>         <CABo5uVt7hq0QnHYqzV5O949h3URGxFOAjHNLxiMx=<br>
>> <a href="mailto:V5rSK_wRw@mail.gmail.com" target="_blank">V5rSK_wRw@mail.gmail.com</a>><br>
>> Content-Type: text/plain; charset="utf-8"<br>
>><br>
>> On Sun, Mar 1, 2015 at 7:37 PM, Rob Parsons <<a href="mailto:jrobparsons@gmail.com" target="_blank">jrobparsons@gmail.com</a>><br>
>> wrote:<br>
>><br>
>> > Hello,<br>
>> ><br>
>> > How do I run scripts located in C:\Program Files (x86)\GRASS GIS<br>
>> > 7.0.0\scripts?<br>
>> ><br>
>> > I am learning GRASS 7.0.0 on Windows 7 by converting some GRASS 6.4<br>
>> shell<br>
>> > scripts to GRASS 7 Python scripts (import grass.script as grass) and<br>
>> GRASS<br>
>> > 7 PyGRASS scripts (from grass.pygrass.modules import Module).<br>
>> ><br>
>> > My installation is working fine. I can manually run the commands (from a<br>
>> > shell script) in the "Command console" window of the "Layer Manager".<br>
>> For<br>
>> > example, I can enter "g.region swwake_30m -p" in the "Command prompt"<br>
>> area<br>
>> > and get the following results:<br>
>> ><br>
>> ><br>
>> > Sun Mar 01 12:32:30<br>
>> > 2015)<br>
>> > g.region swwake_30m<br>
>> > -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<br>
>> > sec)<br>
>> ><br>
>> > I am using the "Pythonwin" IDE to develop the scripts (C:\Program Files<br>
>> > (x86)\GRASS GIS<br>
>> 7.0.0\Python27\lib\site-packages\pythonwin\Pythonwin.exe).<br>
>> > In the "GRASS GIS 7.0.0 GUI" Command Prompt window I type "pythonwin"<br>
>> and<br>
>> > the IDE starts up.<br>
>> ><br>
>> > I have spent several days trying to understand how to create GRASS<br>
>> Python<br>
>> > scripts and GRASS PyGRASS scripts from the online documentation(<br>
>> > <a href="http://grasswiki.osgeo.org/wiki/GRASS_and_Python" target="_blank">http://grasswiki.osgeo.org/wiki/GRASS_and_Python</a>) and by studying the<br>
>> > script samples (C:\Program Files (x86)\GRASS GIS 7.0.0\scripts). I have<br>
>> not<br>
>> > been successful in getting example code to run but I am still working<br>
>> > through the documentation.<br>
>> ><br>
>> > Please try the example from:<br>
>><br>
>> <a href="http://grass.osgeo.org/grass70/manuals/libpython/script_intro.html" target="_blank">http://grass.osgeo.org/grass70/manuals/libpython/script_intro.html</a><br>
>><br>
>> I linked this page from documentation as well as the other Python wiki<br>
>> page<br>
>> from the GRASS and Python page:<br>
>><br>
>> <a href="http://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library" target="_blank">http://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library</a><br>
>><br>
>> Note that GRASS scripts by default cannot run from outside GRASS GIS<br>
>> session (environment). This is probably not emphasized enough in the<br>
>> documentation.<br>
>><br>
>> But, I should be able to run scripts located in C:\Program Files<br>
>> > (x86)\GRASS GIS 7.0.0\scripts.<br>
>> ><br>
>> > Correct?<br>
>> ><br>
>> > Correct but can you please try some other module than a d.* module, e.g.<br>
>> r.out.xyz? d.* commands are somehow special (although in this case it<br>
>> probably doesn't matter).<br>
>><br>
>><br>
>> > 1. If I open .\scripts\<a href="http://d.what.rast.py" target="_blank">d.what.rast.py</a> in the Pythonwin IDE and try to<br>
>> run<br>
>> > 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<br>
>> ><br>
>> 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py",<br>
>> > line 325, in RunScript<br>
>> >     exec codeObject in __main__.__dict__<br>
>> >   File<br>
>> ><br>
>> "C:\Users\Rob\Documents\grassscripts\pygrass\make_raster_using_mapcalc.py",<br>
>> > line 8, in <module><br>
>> >     g.message("Filter elevation map by a threshold...")<br>
>> >   File "C:\Program Files (x86)\GRASS GIS<br>
>> > 7.0.0\etc\python\grass\pygrass\modules\shortcuts.py", line 46, in<br>
>> > __getattr__<br>
>> >     return self.cls('%s.%s' % (self.prefix, name.replace('_', '.')))<br>
>> >   File "C:\Program Files (x86)\GRASS GIS<br>
>> > 7.0.0\etc\python\grass\pygrass\modules\interface\module.py", line 498,<br>
>> in<br>
>> > __init__<br>
>> >     raise GrassError(str_err % <a href="http://self.name" target="_blank">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<br>
>> ><br>
>> 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py",<br>
>> > 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" target="_blank">d.what.rast.py</a>",<br>
>> > 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" target="_blank">d.what.rast.py</a>",<br>
>> > line 30, in main<br>
>> >     options, flags = gcore.parser()<br>
>> >   File "C:\Program Files (x86)\GRASS GIS<br>
>> > 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<br>
>> > 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<br>
>> > 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<br>
>> > 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<br>
>> ><br>
>> 7.0.0\Python27\lib\site-packages\pythonwin\pywin\framework\scriptutils.py",<br>
>> > 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" target="_blank">d.what.rast.py</a>",<br>
>> > 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" target="_blank">d.what.rast.py</a>",<br>
>> > line 30, in main<br>
>> >     options, flags = gcore.parser()<br>
>> >   File "C:\Program Files (x86)\GRASS GIS<br>
>> > 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<br>
>> > 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<br>
>> > 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<br>
>> > 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>
>> ><br>
>><br>
>> This might be somehow related to bug in Python itself:<br>
>><br>
>> <a href="http://bugs.python.org/issue3905" target="_blank">http://bugs.python.org/issue3905</a><br>
>><br>
>> However, please focus on running the scripts for GRASS GIS from GRASS<br>
>> session. The easiest way how to do that on MS Windows is to write the<br>
>> script and then to start it from GUI (File > Run script) or from Python<br>
>> shell tab in the GUI.<br>
>><br>
>> It is possible to run scripts which are using GRASS modules from outside<br>
>> of<br>
>> GRASS session but it requires you to set up the GRASS environment<br>
>> yourself.<br>
>> This is possible but it has some challenges. On the other hand, if you<br>
>> write your script in the way that it runs (only) in a GRASS session you<br>
>> can<br>
>> use GRASS features for automatic building of interface and thus create a<br>
>> true GRASS module.<br>
>><br>
>><br>
>> > 2. If I go to the "Python shell" tab on the "Layer Manager" and do File<br>
>> -><br>
>> > Launch Script and browse to .\scripts\<a href="http://d.what.rast.py" target="_blank">d.what.rast.py</a>, I get this<br>
>> output:<br>
>> ><br>
>> > (Sun Mar 01 12:32:31 2015) Command finished (0<br>
>> > sec)<br>
>> > Launching script 'C:\Program Files (x86)\GRASS GIS 7.0.0\scripts\<br>
>> > <a href="http://d.what.rast.py" target="_blank">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>
>> > The error message seems to be incomplete but in any case, please try<br>
>> with<br>
>> r.out.xyz script and the example script from:<br>
>><br>
>> <a href="http://grass.osgeo.org/grass70/manuals/libpython/script_intro.html" target="_blank">http://grass.osgeo.org/grass70/manuals/libpython/script_intro.html</a><br>
>><br>
>> Vaclav<br>
>><br>
>><br>
>> > Any ideas on what might be going on here?<br>
>> ><br>
>> > Rob Parsons<br>
>> > Raleigh NC<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > grass-user mailing list<br>
>> > <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
>> > <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
>> ><br>
>> -------------- next part --------------<br>
>> An HTML attachment was scrubbed...<br>
>> URL: <<br>
>> <a href="http://lists.osgeo.org/pipermail/grass-user/attachments/20150301/6ff05a0b/attachment.html" target="_blank">http://lists.osgeo.org/pipermail/grass-user/attachments/20150301/6ff05a0b/attachment.html</a><br>
>> ><br>
>><br>
>> ------------------------------<br>
>><br>
>> _______________________________________________<br>
>> grass-user mailing list<br>
>> <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
>> <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
>><br>
>> End of grass-user Digest, Vol 107, Issue 2<br>
>> ******************************************<br>
>><br>
><br>
><br>
> _______________________________________________<br>
> grass-user mailing list<br>
> <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.osgeo.org/pipermail/grass-user/attachments/20150305/74ca5f99/attachment.html" target="_blank">http://lists.osgeo.org/pipermail/grass-user/attachments/20150305/74ca5f99/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
<br>
End of grass-user Digest, Vol 107, Issue 9<br>
******************************************<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>