set the environment variable using python
I basically want to set path for some of the variables using source . Scripting language python .subprocess.call call source /home/local/APPSCRIPT.env but not actually setting the environment variable. sample script : import os from subprocess import Popen, PIPE import subprocess subcall=subprocess.call(['source /home/local/APPSCRIPT.env'],shell=True) Please suggest how can i set the environment variable from APPSCRIPT.env APPSCRIPT.env : export xxx_SIZE=1 export yyy_USE=FALSE export zzz_INCREMENTAL=FALSE
You can't do this. subprocess runs in, well, a subprocess. There's no way for any environment changes made in a subprocess to affect the calling process. The only way to change environment variables for the current process in Python is to directly modify the sys.environ dictionary.
you have to use export the_variable_name = something in your .env file so that you can access the variable from the .env to any python file
Can't compile msgpack Python extension under windows
Python sockets for a n-players game
HTMLParser or urllib2 unicode issue
How to stop PyCharm inserting spaces for fine alignment when reformating code?
Install NLTK with IronPyton for VS2012
pip install won't install on my machine
Integrating using scipy.integrate.simps
Problems with django and virtualenv
Returning when any Future in a list finishes
Python Django - matching query does not exist when using pk
R translation to Python
Are there downsides to using Python locals() for string formatting? [duplicate]
Compiled Python writing to Program Files
How to synchronize multiple django settings to the DB?
simulate pulling marbles from a bag without replacement (efficiently)
Datetime string doesn't match after strftime() and strptime()