2016-11-14 46 views
2

3方案,以獲得低於$ PATH:1)從終端2)從Python從航站樓3)推出在Python(IDLE)

1)終端:>> echo $PATH導致列表的〜10-15位置

2)運行Python在終端:

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

3)現在我運行python IDLE(因此,不運行終端)

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

問:如何更改$ PATH,以便影響Python IDLE?我發現了一些建議,從.bash_profile更新$ PATH,但看起來像只在運行終端時影響$ PATH。

我也考慮過/ etc/paths,但仍然有一個位置(/ usr/loca/bin /)存在於3D場景中。那麼基本上Mac OS X中$ PATH變量的來源是什麼?

+0

這個問題應該有你正在尋找的答案:http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-優勝美地 –

回答

1

變量$ PATH由.bash_profile更改,它在啓動終端時執行。在你的情況下,你應該通過例如蘋果工具path_helper編輯/etc/paths.d/(見here)。

+0

我想你錯過了這個問題。 IDLE輸出不同的信息 –

+0

因此,實際上path_helper在Python IDLE不打印時打印'/ usr/local/bin /'。這是否意味着Python IDLE具有自己的設置或加載了/ etc /路徑,但是通過其他設置刪除了一些位置? –

+1

變量'PATH'通常由'.bash_profile'設置,但這隻適用於在終端中運行的程序,並且只有在您的shell設置爲Bash的情況下。 –

相關問題