<div dir="ltr">Dear Dave Angel<div><br></div><div>Thanks for your answer.</div><div><br></div><div>I am using Python 2.7</div><div><br></div><div>I want to set it permanently.</div><div>I have to set several variables so it would be easier if I could set them from Python.</div><div><br></div><div>Hearing the solution.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 31, 2014 at 10:50 AM, Dave Angel <span dir="ltr"><<a href="mailto:davea@davea.name" target="_blank">davea@davea.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 10/30/2014 09:22 PM, Artur Bercik wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have to set environmental variable in my windows PC as follows:<br>
<br>
variable name: GISBASE<br>
<br>
value: C:\GRASS-64<br>
<br>
Is it possible to set it from python?<br>
</blockquote>
<br></span>
Which Python?  I'll have to assume 3.x<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
import sys<br>
<br>
sys.path.append("C:\\GRASS-64"<u></u>)<br>
<br>
But how to give variable name? I have to set both the variable name and<br>
value.<br>
<br>
</blockquote>
<br></span>
sys.path has nothing to do with an environment variable of GISBASE.<br>
<br>
Instead you could look up os.environ at:<br>
<br>
      <a href="https://docs.python.org/3/library/os.html" target="_blank">https://docs.python.org/3/<u></u>library/os.html</a><br>
<br>
Also see os.getenv and os.setenv.<br>
<br>
<br>
<br>
Note that it's not necessarily supported.  But I believe it is for a standard build on Windows.<br>
<br>
Next question is what you hope to achieve by setting such a variable. You do realize that it will vanish again when your python process ends?  So if you're just planning to use it in your own code, I'd recommend finding another method of saving the name & value.<br>
<br>
The only value I can see is if you plan to create a subprocess from your Python code.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
DaveA<br>
-- <br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>