2

3 scenarios to get $PATH below: 1) from Terminal 2) from Python launched from Terminal 3) from Python (IDLE)

1) In terminal: >> echo $PATH leads to the list of ~10-15 locations

2) Run Python in terminal:

>> python
>> os.environ['PATH']
>> # I get the same list as in the first scenario. Expected

3) Now I run python IDLE (so, don't run Terminal)

>> os.environ['PATH']
>> # I get different list of paths. much less locations comparing to 1 or 2 scenarios.

Q: how do I change $PATH such that it affects Python IDLE? I found some recommendations to update $PATH from .bash_profile, but looks like they affect $PATH only when I run Terminal.

I also considered /etc/paths, but still there is a location (/usr/loca/bin/) there that is missed in 3d scenario. So what is basically the origin of $PATH variable in Mac OS X?

Daria Ivanova
  • 167
  • 1
  • 4
  • 15
  • This question should have the answers you are looking for: http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite – Dietrich Epp Nov 14 '16 at 03:42

1 Answers1

1

The variable $PATH is changed by .bash_profile, which is executed when you start the terminal. In your case, you should edit /etc/paths.d/ via, for example, the Apple tool path_helper (see here).

  • I think you missed the question. IDLE prints different information – OneCricketeer Nov 14 '16 at 00:40
  • so, actually path_helper does print '/usr/local/bin/' while Python IDLE doesn't. Does it mean that Python IDLE has its own setting or it loads /etc/paths but then removes some locations by some other settings? – Daria Ivanova Nov 14 '16 at 00:43
  • 2
    The variable `PATH` is often set by `.bash_profile` but that's *only* for programs that run in the terminal and only if your shell is set to Bash. – Dietrich Epp Nov 14 '16 at 03:37
  • Have you tried to update the PATH variable in the `.profile` file instead of in the `.bash_profile` one? – Davide Valeriani Nov 15 '16 at 02:57