3

I can't access my env var:

import subprocess, os
print os.environ.get('PATH') # Works well
print os.environ.get('BONSAI') # doesn't work

But the env var is well added in my /home/me/.bashrc:

BONSAI=/home/me/Utils/bonsai_v3.2
export BONSAI

And I can access this env var from a new terminal.

lcd047
  • 5,731
  • 2
  • 28
  • 38
hayj
  • 1,159
  • 13
  • 21

1 Answers1

6

After updating your .bashrc, perform source ~/.bashrc to apply the changes.

Also, merge the two BONSAI-related calls into one:

export BONSAI=/home/me/Utils/bonsai_v3.2

UPDATE: It was actually an attempt to update the environment for some Eclipse-based IDE. This is a different usecase altogether. It should be described in the Eclipse help. Also, a similar question was answered here.

Community
  • 1
  • 1
Eugeniu Rosca
  • 5,177
  • 16
  • 45
  • I added export BONSAI=/home/me/Utils/bonsai_v3.2 in /etc/profile also and perform a source /etc/profile but it still does'nt work – hayj Jun 22 '15 at 14:21
  • Try the one-liner: `export BONSAI=/home/me/Utils/bonsai_v3.2; python `. What is the result? – Eugeniu Rosca Jun 22 '15 at 14:23
  • It works but I want to use eclipse... so I need to access to the env var anywhere... – hayj Jun 22 '15 at 14:31
  • 1
    Have you restarted your eclipse IDE after updating the `.bashrc` or the `/etc/profile` ? Are you sure your eclipse IDE inherits the environment specified in `.bashrc` or `/etc/profile`? – Eugeniu Rosca Jun 22 '15 at 14:32
  • Yes but maybe I must restart the computer, I try – hayj Jun 22 '15 at 14:33
  • You should check how new environment variables are added to the Eclipse IDE. Maybe [this](http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_run_env.htm) can help. – Eugeniu Rosca Jun 22 '15 at 14:37