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

Numpy: Drop rows with all nan or 0 values
python argparse print usage text after description
python equivalent for php mcrypt tripledes
How to handle a raw buffer with boost::python
How to configure logging in python with different modules writing to the same destination
Run code before and after each test in py.test?
How to take the sum of a float list?
Django Delete Objects
Rate Limit an Infinite While Loop in Python
Unable to find virtualenv or django after installing with pip
Dynamically naming tuples for redis
Django - accessing foreignkey's attribute
How can I use \r to make Python print on the same line?
Python to search a string for the first occurrence of any item in a list
Fetch and write CLOB type values from oracle to a file
Pandas calculate days elapsed and percent change

Categories

HOME
batch-processing
meshlab
oauth
voip
otrs
command
transparent
h2
mainframe
flyway
phonegap-cli
ios10
jboss-eap-7
cortex-a
store
equalizer
symfony2-easyadmin
typeahead
eclipse-luna
jpeg2000
movies
zend-framework-mvc
jsonserializer
propel2
plupload
jni
rails-activerecord
fop
samsung-mobile
shopping-cart
guile
codelite
excel-2013
classpath
pentaho-report-designer
i3
pep8-assembly
superscript
ivy
jboss5.x
vegan
smart-mobile-studio
freebase
data-extraction
von-neumann
remote-server
nlb
broadleaf-commerce
.net-assembly
sonarqube-scan
constants
3scale
openweathermap
floor
recycle-bin
component-pascal
slidesjs
tofixed
ingres
windows-azure-pack
excon
git-annex
pax-web
spinlock
difference
cctray
sonarqube5.3
throughput
android-viewholder
eyeql
zuora
site-prism
matcaffe
rad
registrykey
connection-reset
debian-based
stackframe
ticket-system
python-ggplot
pgagent
cpu-speed
kendo-mvvm
qtestlib
dmp
genetic-programming
ember-addon
zipalign
flash-cc
mimosa
modeshape
sslexception
robospice
nimrod
swrl
mailcore
fieldset
bulbs
maven-ear-plugin
css-tables
autostart
datarepeater
redirectstandardoutput
file-exists
supersized
point-sprites
emacs23
path-manipulation
objectbrowser
nsindexpath
handwriting
paintcomponent
authenticode
.app
carbide
hadoop-plugins
iphone-sdk-3.2
mvvm-foundation
document-library

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