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

TypeError: unorderable types: Study() < int() [duplicate]
If conditon to get exceeded value if it goes above threshold from file
Python sqlalchemy - independent transactions
Django - How to create a simple confirmation view?
Python tkinter - Button callback function [duplicate]
Print text file with python
from a single user to multiple users Django app
Emacs fails to run Python code
Extract data from first column of a certain row using scrapy python
Keras CNN model stops
python, code works find without looping, then have unsupported operand type
How to clear all the values of a Form before starting new unit test case in selenium using python
How can I debug my python code in POST method of web py?
Group data based on column name pandas
Spyder runfile from other script
wxpython don't capture EVT_HELP

Categories

HOME
sharepoint
elixir
jsviews
google-contacts
jbehave
playframework
parse-server
zend-framework2
chaiscript
vlc
phaser-framework
filter
apiconnect
deeplearning4j
shipping
wicket
xlsx
tee
sign
symfony2-easyadmin
cloudflare
uisplitviewcontroller
uicollectionview
android-fragmentactivity
google-maps-android-api-2
sensu
autolayout
jquery-scrollify
myob
logarithm
croppic
java-ee-7
mef2
pptp
reactiveui
mangodb
referenceerror
percentage
ocs
google-guava-cache
pace
color-scheme
wsadmin
web-development-server
distributed-transactions
tango
lftp
3scale
lirc
jtds
nstouchbar
azureportal
shutdown
component-pascal
etherpad
qos
sqlexception
emgu
master
ebtables
typhoon
backstop.js
django-south
handlebars.java
loose-typing
getrusage
affix
apigee-baas
isml
google-hadoop
consensus
ejabberd-saas
alphablending
codeigniter-a3m
opensocial
gfs
baucis
facebook-chat
installshield-2011
threadx
argb
lame
pep8
abnf
dynamic-data
moq-3
sunspot-rails
continuous-testing
unions
entity-framework-ctp5
mysql-error-1045
selectmanycheckbox
rijndael
hibernate3-maven-plugin
dirty-data
rd





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