Obtain the variable in bash.

Chris Angelico rosuav at gmail.com
Wed Mar 23 03:19:04 EDT 2016


On Wed, Mar 23, 2016 at 6:12 PM, Hongyi Zhao <hongyi.zhao at gmail.com> wrote:
> I exported a variable in my .bashrc as follows:
>
> export MY_VAR="fdsfads"
>
> Then I soured the .bashrc and do the testing as follows:
>
> werner at debian-01:~$ python -c "import os; print os.environ['MY_VAR']"
> fdsfads
>
> But, when I run the same commands in pycharm and wing ide, I failed the
> obtain the value of this variable.
>
> I'm very confused with this issue.
>

Did you start pycharm/wing from the same session in which you sourced
.bashrc? If not, they won't see that change.

My guess is that you started the IDEs from your GUI in some way (the
Applications menu or something). If that's the case, they'll inherit
their environment from your GUI. You _may_ be able to have them
"notice" your change to .bashrc by logging out and in again, or
rebooting; it depends how your system is configured.

ChrisA



More information about the Python-list mailing list