Issue
I'm trying to set the environment variable of my .bashrc
using Spyder; in other words I'm looking for a python command that reads my .bashrc
. Any idea?
Solution
.bashrc
should automatically be loaded into the environ on login
import os
print os.environ
if you wanted to create a dictionary of values from a bash source file you could in theory do something like
output = subprocess.check_output("source /path/to/.bashrc;env")
env = dict(line.split("=") for line in output.splitlines() if "=" in line))
print env
Answered By - Joran Beasley
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.