下面 3 种获取 $PATH 的场景:1)从终端 2)从终端启动的 Python 3)从 Python(空闲)
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,但在 3d 场景中仍然遗漏了一个位置 (/usr/loca/bin/)。那么 Mac OS X 中 $PATH 变量的基本来源是什么?
最佳答案
变量 $PATH 由 .bash_profile 更改,它在您启动终端时执行。在您的情况下,您应该通过例如 Apple 工具 path_helper
编辑 /etc/paths.d/
(请参阅 here)。
关于python - MacOS 塞拉利昂 : modify $PATH globally,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40580358/