I am using c-shell and I am used to using setenv. I need to execute an equivalent command from within a python script. I tried using os.environ[‘JAVA_HOME’] = “/usr/local/java” which works from the python interpreter, but when my script is executed from the command line, the shell it ran in does reflect the newly set environment variable. Can anybody help, I am new to scripting, I hope I made my question clear.
Share
If you’re using
subprocess.Popen, it should be enough to pass theenvparameter to the constructor to whatever you need as a dictionary (you can copy the contents ofos.environand add your own environment variables if you wish).