<html style="direction: ltr;">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body bidimailui-detected-decoding-type="latin-charset"
style="direction: ltr;" text="#000000" bgcolor="#FFFFFF">
<p>Just a guess...</p>
<p>You are repeatedly adding the path to GRASS to your environment
variable "PATH" until it becomes longer than allowed. </p>
<p>I would say, open *one* session (in main()), then run your
processing loop.</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 22/08/2019 01:49, Moody, Alex wrote:<br>
</div>
<blockquote type="cite"
cite="mid:8B8D710C04766344A7F8A9FD08F4E357D052AC@DWRBOIMB03.dwrprod.idaho.gov">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi all,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I consistently have an issue where I am
running long loops for raster processing that crash after 100
iterations or so. Typically the error is a ValueError where
“ValueError: the environment variable is longer than 32767
bytes”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This has happened when running scripts in
the GUI and when using the grass_session package. A sketch of
my loop is as follows:
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">def
doSomething(x):<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> user =
Session()<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
user.open(gisdb=mygisdb, location=mylocation,
mapset=mymapset,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
create_opts='')<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
v.surf_idw(….)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
r.out_gdal(…)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
user.close()<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">def main():<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> monthlist =
list of dates<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> for month
in monthlist:<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
doSomething(month)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">if __name__ ==
"__main__":<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
sys.exit(main())<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""><o:p> </o:p></span></p>
<p class="MsoNormal">So I’m opening and closing a session in
each loop, which I hoped would take care of memory Issues I
may run into.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m using 7.6.1 on a 64-Bit Windows 7. The
full error is<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">Traceback (most
recent call last):<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> File
"D:\TreasureValley\waterbudget\riparian\et_interpolate_refet.py",
line 82, in <module><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
sys.exit(main())<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> File
"D:\TreasureValley\waterbudget\riparian\et_interpolate_refet.py",
line 79, in main<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">
makeETrSurface(ts)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> File
"D:\TreasureValley\waterbudget\riparian\et_interpolate_refet.py",
line 30, in doSomething<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> user =
Session()<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> File
"D:\OSGEO4~1\apps\Python27\lib\site-packages\grass_session\session.py",
line 244, in __init__<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> self.env =
set_grass_path_env(gisbase=self.gisbase, env=self.env)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> File
"D:\OSGEO4~1\apps\Python27\lib\site-packages\grass_session\session.py",
line 102, in set_grass_path_env<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> env['PATH']
+= os.pathsep + os.path.join(gisbase, 'extrabin')<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> File
"D:\OSGEO4~1\apps\Python27\lib\os.py", line 422, in
__setitem__<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New""> putenv(key,
item)<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span
style="font-family:"Courier New"">ValueError: the
environment variable is longer than 32767 bytes</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any ideas of how to prevent the ValueError?
Perhaps some arguments when calling Session?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks as always,<o:p></o:p></p>
<p class="MsoNormal">Alex<o:p></o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a></pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
+972-523-665918</pre>
</body>
</html>