macOS – Fix ‘Service Cannot Initialize’ Error in Console for plist Files

launchdmacosplist

I have set up a plist file and loaded/started it with launchd. Whenever it is time for the script to run, I receive the following error in my console:

12/9/15 12:53:19.344 PM com.apple.xpc.launchd[1]: (kjuvbot[742]) Service could not initialize: 14F27: xpcproxy + 13421 [1402][AD0301K4-D354-31AE-8BA7-B5KBECE64P0B]: 0x2

Does anyone have any idea why this error might occur? Here is my .plist file:

kjuvbot.plist

<?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>kjuvbot</string>
    <key>ProgramArguments</key>
    <array>
        <string>python3</string>
        <string>/Users/me/workspace/Learning/src/kjuvbot.py</string>
    </array>
    <key>StartInterval</key>
    <integer>3600</integer>
</dict>
</plist>

Does it by chance need com. in front of the filename?

Here are the permissions (I created the file as myself):

-rw-r--r--@ 1 me  staff  427 Dec  9 19:28 kjuvbot.plist

Best Answer

python3 is not in the path used by launchd which will be less that that in the terminal.

Try using the full path in the plist

e.g.

<key>ProgramArguments</key>
<array>
    <string>/usr/local/bin/python3</string>
    <string>/Users/me/workspace/Learning/src/kjuvbot.py</string>
</array>