Reputation: 437
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
Upvotes: 0
Views: 391
Reputation: 599956
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.
Upvotes: 2