keep in mind that shell settings made within program usually endure only for that program' run and for the run of its spawned children if you need to export shell variable setting so that it lives on after python exitsyou may be able to find platformspecific extensions that do thissearch another subtletyas implemented todaychanges to os environ automatically call os putenvwhich runs the putenv call in the library if it is available on your platform to export the setting outside python to any linked-in code howeveralthough os environ changes call os putenvdirect calls to os putenv do not update os environ to reflect the change because of thisthe os environ mapping interface is generally preferred to os putenv also note that environment settings are loaded into os environ on startup and not on each fetchhencechanges made by linked-in code after startup may not be reflected in os environ python does have more focused os getenv call todaybut it is simply translated into an os environ fetch on most platforms (or allin )not into call to getenv in the library most applications won' need to careespecially if they are pure python code on platforms without putenv callos environ can be passed as parameter to program startup tools to set the spawned program' environment standard streams the sys module is also the place where the standard inputoutputand error streams of your python programs livethese turn out to be another common way for programs to communicateimport sys for in (sys stdinsys stdoutsys stderr)print(fencoding='cp 'encoding='cp 'encoding='cp 'the standard streams are simply preopened python file objects that are automatically connected to your program' standard streams when python starts up by defaultall of them are tied to the console window where python (or python programwas started because the print and input built-in functions are really nothing more than userfriendly interfaces to the standard output and input streamsthey are similar to using stdout and stdin in sys directlyprint('hello stdout world'hello stdout world sys stdout write('hello stdout world'\ 'hello stdout world standard streams