To configure the environment for a specific task, you must use the EnvironmentVariables key in the task definition itself:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.example.app</string> <key>Program</key> <string>/path/to/your/script</string> <key>EnvironmentVariables</key> <dict> <key>PYTHONPATH</key> <string>/your/python/path</string> </dict> </dict> </plist>
You can define default environment variables for launchd(8) services by editing /etc/launchd.conf for daemons or /etc/launchd-user.conf for agents. The latter works, but is not documented. Currently registered (but not supported) configuration file for each user $HOME/.launchd.conf .
These configuration files contain a list of launchctl(1) subcommands. Do you want to:
setenv PYTHONPATH /your/python/path
Update: /etc/launchd.conf not supported on Mac OS X 10.10 or higher. On these systems, you will have to define environment variables based on each job.
source share