I want to use a value from an environment variable. I have set it in the ~/.bashrc file and I am able to see that in the new shells and in the current shell(obviously, after sourceing it). However, when I import the same variable in Python3 shell(both in the existing and in the new shells), the value returned is always None.
I read a lot and found a relatable answer but it did not solve my problem or rather, I could not understand it.
My bashrc file is:
SLACK_URL="https://hooks.slack.com/" I am able to see the value in the terminal but not in the Python shell:
[email protected]:~$ echo $SLACK_URL https://hooks.slack.com/ [email protected]:~$ python3 Python 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.getenv('SLACK_URL') >>> I expect to see the actual variable's value but instead I am getting None.
exportwhen defining the env var.