Your example didn't try to define the variable, it only attempted to look at it's current value
try this >> C:\Tmp>set LANG >> Environment variable LANG not defined C:\tmp> set LANG="SOME_LANGUAGE" set LANG LANG="SOME_LANGUAGE" Message: 5 Date: Tue, 10 May 2005 10:54:13 -0700 From: Tim Roberts <[EMAIL PROTECTED]> Subject: Re: [python-win32] Setting environment variables in windows from Python Programs To: python-win32@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed On Mon, 9 May 2005 16:23:08 -0700, Nalli Dinesh <[EMAIL PROTECTED]> wrote: >This seems very easy, as every programming language provides this. But >I don;t know why I have this not working for me in Python scripts. >The problem: >I am trying to create and set environment variable LANG under windows >from Python file. I am using OS module's putenv or environ to do so. >But it is not really creating the environment variable or neither set >the same from the code. >This seems to be a easy fix, if anyone has a reason and fix for this >problem, please shoot it back to me. I am using python2.4 > > Paul is exactly right. You cannot change the environment of the shell from which you started, in any language, on any (popular) operating system. You can only affect your own environment, and those of any processes you start. This is usually enough: C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp>python Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ['LANG'] Traceback (most recent call last): File "<stdin>", line 1, in ? File "c:\apps\python23\lib\os.py", line 417, in __getitem__ return self.data[key.upper()] KeyError: 'LANG' >>> os.environ['LANG']='language' >>> os.system('set L') LANG=language LIB=C:\VS.NET\VC7\ATLMFC\LIB;C:\VS.NET\VC7\LIB;C:\VS.NET\VC7\PlatformSDK\lib\pre release;C:\VS.NET\VC7\PlatformSDK\lib;C:\VS.NET\SDK\v1.1\lib; LOGNAME=timr LOGONSERVER=\\DOUG 0 >>> ^Z C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp> _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32