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

Can't compile msgpack Python extension under windows
Python sockets for a n-players game
HTMLParser or urllib2 unicode issue
How to stop PyCharm inserting spaces for fine alignment when reformating code?
Install NLTK with IronPyton for VS2012
pip install won't install on my machine
Integrating using scipy.integrate.simps
Problems with django and virtualenv
Returning when any Future in a list finishes
Python Django - matching query does not exist when using pk
R translation to Python
Are there downsides to using Python locals() for string formatting? [duplicate]
Compiled Python writing to Program Files
How to synchronize multiple django settings to the DB?
simulate pulling marbles from a bag without replacement (efficiently)
Datetime string doesn't match after strftime() and strptime()

Categories

HOME
jsf
ibm-watson-cognitive
vs-team-services
puppet
windows-store-apps
eval
dropbear
ipfs
getorgchart
window
pjsip
store
pdo
uisplitviewcontroller
ms-access-2007
onsen-ui
remove-method
rworldmap
searchbar
auditing
croppic
katharsis
java-ee-7
dss
cortex-m3
pep8-assembly
lmdb
fractals
mapguide
lego
swagger-editor
mongoexport
silverlight-3.0
agent
rule
sendgrid-templates
facebook-chatbot
taskmanager
data-integration
sapui
broadcast
tiddlywiki
spell-checking
mercury
addin-express
lotus
objloader
gradle-script-kotlin
picasa
debugdiag
chessboard.js
gameanalytics
angularjs-ng-pattern
webkit2
windows-nt
com-interop
soda
mpeg-4
anti-cheat
fill
handlebars.java
self-hosting
rad
p-np
vine
playscape
on-duplicate-key
manjaro
rx-groovy
graphical-logo
cpu-cores
gray-code
httpie
google-plus-one
uptodate
activity-streams
ultrawingrid
mser
scala-2.11
cg
log4cplus
korma
dvcs
map-force
visualstatemanager
cilk-plus
awesomeprint
vertical-scrolling
dropdownlistfor
caliper
hobo
ou
goliath
gtk2hs
associative
squeel
j-interop
osx-leopard
webrat
oggvorbis
callgrind
longjmp
odbc-sql-server-driver

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