I want to set an environmental variable in linux terminal through a python script. I seem to be able to set environmental variables when using os.environ['BLASTDB'] = '/path/to/directory'
.
However I was initially trying to set this variable with subprocess.Popen
with no success.
import subprocess
import shlex
cmd1 = 'export BLASTDB=/path/to/directory'
args = shlex.split(cmd1)
p = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
Why does subprocess.Popen
fail to set the environmental variable BLASTDB to '/path/to/directory'?
NOTE: This also fails when using:
import os
os.system('export BLASTDB=/path/to/directory')