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
How to redirect printed value of python script to the linux terminal as a command
Selenuim webdriver fails without notice for ssl error
Unable to locate button element using selenium webdriver
Simple Image Deconvolution issue
In Python, what is the easiest way to add a list consisting of keyword pairs to a dictionary?
I can't find what's wrong with this circle bounce calculation in python
Determine Postgresql datatype for a variable in Ruby, Python, or C++?
Z3 v4.3.2 example.py execution error on Mac OS X 10.10
How do I specify the root module directory in python?
Python, xml.dom, and parsing
Find all string positions in file
Python use request to login
how to delete a tempfile later
How do I flatten nested lists of lists in python?
How can I get a string(Mix of digit and char) up to last digit using regex in python?
Plotting python object attribute and objects are stored in list