python - MacOS 塞拉利昂 : modify $PATH globally

标签 python macos environment-variables macos-sierra

下面 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/

相关文章:

python - pymunk + tkinter : How to get ball to move to left or right with pymunk?

python - 如何获取Numba字典的大小?

python - 安装 mlxtend 时权限被拒绝 (Python 3)

bash - 如何在 bash "for loop"中使用 ffmpeg 流复制?

nginx - Nginx.conf可以访问环境变量吗?

python - 是否可以将我机器上的环境变量推送到 GitHub?

python - 使用 pandas 将字符串值重新映射到新标签

macos - 如何 : Set up a Virtual Host on Apache 2. 4.4 [MAC/*NIX]

macos - 从 iOS 开发转向 Mac 开发

python - 如何从 python 脚本内部运行 python 命令?