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
Numpy convert list of 3D variable size volumes to 4D array
Django: Dynamic “table of contents” based on HTML tags
What does Random Forest do with unseen data?
Python Eve fails to run on newly created droplet
Django external url, csrf
Most concise way to select rows where any column contains a string in Pandas dataframe?
Moving desired row to the top of pandas Data Frame
How can I get virtualenv to work?
How to delete “u'” before the attributes [duplicate]
Extrange behavior with multilevel SQLAlchemy inheritance
How to handle dynamically changing UIElements in atomac/python?
odoo get the value of maximum array index
scrapy-redis re-crawl the url that one machine has already crawled
Python getting element value for specific element
Python: OpenGL Error 1280 Invalid Enumerant with glEnd()
Reviving pandas KeyErrors seemingly at random, without changing my code. Possible memory errors?