Change environment variables persistently with Python -


is possible using python 3.5 create , update environment variables in windows , linux persisted?

at moment use this:

import os os.environ["my_variable"] = "true" 

however seems if not "store" environment variable persistently.

i'm speaking linux here, not sure windows.

environment variables don't work way. part of process (which modify changing os.environ), , propagate child processes of process (and children obviously). in-memory only, , there no way "set , persist" them directly.

there several configuration files allow set environment on more granular basis. these read various processes, , can system-wide, specific user, specific shell, particular type of process etc.

some of them are:

  • /etc/environment system-wide variables
  • /etc/profile shells (and children)
  • several other shell-specific files in /etc
  • various dot-files in user's home directory such .profile, .bashrc, .bash_profile, .tcshrc , on. read shell's documentation.
  • i believe there various ways configure environment variables launched guis (e.g. gnome panel or that).

most of time you'll want set environment variables current user only. if care shells, append them ~/.profile in format:

name="value"


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -