Why is Python unable to retrieve value of an environment variable even though that variable has value when tested via bash? : <p>I want to use a value from an environment variable. I have set it in the <code>~/.bashrc</code> file and I am able to see that in the new shells and in the current shell(obviously, after <code>source</code>ing 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 <code>None</code>.</p>

<p>I read a lot and found a <a href="https://stackoverflow.com/questions/31993885/why-cant-python-see-environment-variables">relatable answer</a> but it did not solve my problem or rather, I could not understand it.</p>

<p>My bashrc file is:</p>

<pre><code>SLACK_URL="https://hooks.slack.com/"
</code></pre>

<p>I am able to see the value in the terminal but not in the Python shell:</p>

<pre><code>ubuntu@ip-A.B.C.D:~$ echo $SLACK_URL 
https://hooks.slack.com/
ubuntu@ip-A.B.C.D:~$ 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.
&gt;&gt;&gt; import os
&gt;&gt;&gt; os.getenv('SLACK_URL')
&gt;&gt;&gt; 
</code></pre>

<p>I expect to see the actual variable's value but instead I am getting <code>None</code>.</p>
