python


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

Related Links

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

Categories

HOME
cakephp-3.x
cil
sed
webrtc
decorator
deep-linking
actionscript
parse-server
apollo
appmaker
terrain
jframe
google-classroom
xamarin-studio
cosmicmind
cratedb
typeahead
datagrip
lenskit
reduction
apache-karaf
arraylist
ada
ng-show
prestodb
uiautomator
spring-test
metis
maximo
edge-detection
superagent
postgresql-9.2
read-write
construct-2
canvasjs
viewstate
windows-10-iot-core
pace
bigcartel
dart-pub
web-development-server
jupyter-console
spring-bean
powermta
python-idle
dojox.grid.datagrid
openweathermap
gd
sgmlreader
scd
gce
opencpu
svn-merge
objloader
iostat
tomee
uistackview
activeweb
software-product-lines
git-annex
pax-web
uwp-maps
freefem++
asp.net-mvc-2
schtasks.exe
datasnap
sem
response-headers
paypal-nvp
shift-jis
tcpreplay
x-ua-compatible
cg
node-imagemagick
suffix-array
csplit
eclipse-classpath
mbox
bounds
sslexception
multiple-conditions
graph-coloring
qt4.6
android-contextmenu
cadisplaylink
hibernate3
querystringparameter
coff
handwriting
pivotal-crm
loadui
mvvm-foundation
soft-keyboard
configurable
dotproject

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App