在 Mac 上设置环境变量(特别是 PYTHON PATH)
因为获取这个简单的信息是一项艰巨的任务,所以我决定将其发布给其他人:
- 在终端执行: mkdir ~/.MacOSX
- 在终端执行: touch ~/.MacOSX/environment.plist
- 浏览到文件并打开。
粘贴:
DISPLAY ; <字符串>:0.0 <键>PYTHONPATH/full/path/ofyour/favorite/script/dir:/full/path/of/another/script/dir: 编辑您需要的内容并保存。
Because it was such a mission to get this simple bit of info I've decided to post it for others:
- In terminal execute: mkdir ~/.MacOSX
- In terminal execute: touch ~/.MacOSX/environment.plist
- Browse to the file and open.
Paste:
<key>DISPLAY</key> <string>:0.0</string> <key>PYTHONPATH</key> <string>/full/path/ofyour/favorite/script/dir:/full/path/of/another/script/dir:
Edit to what you need and save.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是使用 属性列表编辑器 执行此操作的记录方法。
请注意,以这种方式设置环境变量时应谨慎,因为它们适用于启动的 GUI 应用程序,而这些应用程序可能不期望它们。要在终端 shell 中工作时设置默认环境变量,首选使用 shell 配置文件命令(例如
.profile
或.bash_profile
)的传统 UNIX 方式,并且不太可能破坏内容。Here is the documented way to do it with Property List Editor.
Note that you should use caution when setting environment variables this way as they apply to launched GUI applications which might not be expecting them. For setting default environment variables when working in a terminal shell, the conventional UNIX way of using shell profile commands, like
.profile
or.bash_profile
is preferred and less likely to break things.mkdir ~/.MacOSX
touch ~/.MacOSX/environment.plist
:
编辑为您需要的内容并保存。
(这是由原始发布者作为问题的一部分编写的。重新发布为社区维基,因为我没有编写它,只是清理了格式。)
mkdir ~/.MacOSX
touch ~/.MacOSX/environment.plist
Edit to what you need and save.
(This was written by the original poster as part of the question. Reposted as community wiki because I didn't write it, just cleaned up the formatting.)