Setting environment variables (specifically the PYTHON PATH) on a mac
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.
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.
- In terminal execute:
mkdir ~/.MacOSX
- In terminal execute:
touch ~/.MacOSX/environment.plist
- Browse to the file and open.
- Paste:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DISPLAY</key>
<string>:0.0</string>
<key>PYTHONPATH</key>
<string>/full/path/ofyour/favorite/script/dir:/full/path/of/another/script/dir:</string>
</dict>
</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.)
精彩评论