I have a Python 2.7 app that uses Tkinter. The problem is that I cannot read the environment variables I defined when I use Tkinter.
Was thinking this was a problem I am having with Python/Tkinter app, or how I am defining my environment variable or both. I have tried defining an environment variable in /etc/environment and /etc/profile folders on a Raspberry Pi 2 as the following
EXPORT USR_USR="ccj63078"
What is strange is I can read $PATH $HOME.
To debug I stripped my app down to this writing the contents to a text file.
#!/usr/bin/python
import os, Tkinter
top = Tkinter.Tk()
vusr_usr = os.environ.get('USR_USR')
user_envd = open('user_envd.txt','w+')
user_envd.write('v_usr= ' + str(vusr_usr) + '\n')
user_envd.close()
top.mainloop()
I am not understanding why I can read PATH or HOME, but not one that I defined?
vusr_usrequal toNone? Also, did you reboot after adding the lineUSR_USR="whatever"to your/etc/environment(note: you don't needexportthere)? Also worth checking: what do you get if you runprint os.environ(e.g. in IDLE)?