开发者

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:

  1. 开发者_高级运维In terminal execute: mkdir ~/.MacOSX
  2. In terminal execute: touch ~/.MacOSX/environment.plist
  3. Browse to the file and open.
  4. Paste:

        <key>DISPLAY</key>
    
        <string>:0.0</string>
    
        <key>PYTHONPATH</key>
    
        <string>/full/path/ofyour/favorite/script/dir:/full/path/of/another/script/dir:
    

  5. 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.


  1. In terminal execute: mkdir ~/.MacOSX
  2. In terminal execute: touch ~/.MacOSX/environment.plist
  3. Browse to the file and open.
  4. 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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜