How to set the python environment for LaunchDaemons I have installed Python 3 via Homebrew, on my Mojave system, and have it symlinked to /usr/local/bin/python.

I have a LaunchDaemon plist as follows:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;test&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
          &lt;string&gt;python&lt;/string&gt;
          &lt;string&gt;--version&lt;/string&gt;
        &lt;/array&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;&lt;true/&gt;
        &lt;key&gt;KeepAlive&lt;/key&gt;&lt;true/&gt;

        &lt;key&gt;EnvironmentVariables&lt;/key&gt;
        &lt;dict&gt;
            &lt;key&gt;PATH&lt;/key&gt;
            &lt;string&gt;/usr/local/bin/python3&lt;/string&gt;
            &lt;key&gt;PYTHONPATH&lt;/key&gt;
            &lt;string&gt;/usr/local/lib/python3.7/site-packages&lt;/string&gt;
        &lt;/dict&gt;

        &lt;key&gt;StandardOutPath&lt;/key&gt;
        &lt;string&gt;/var/log/test.log&lt;/string&gt;
        &lt;key&gt;StandardErrorPath&lt;/key&gt;
        &lt;string&gt;/var/log/test_err.log&lt;/string&gt;

    &lt;/dict&gt;
&lt;/plist&gt;



However, this still returns Python 2.7.10 which is installed by default on the Mojave system.

How do I set the path up for this LaunchDaemon so that is has access to the Python 3 environment instead?



Additional info:

For the full plist I am using, the program calls python at some point (python isn't the entry point), hence requiring the PYTHONPATH being set to point to the site-packages where some additional packages have been installed.

The error which pops up there is:

Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python 2.x!
     PYTHONPATH is currently: "/usr/local/lib/python3.7/site-packages"
     You should `unset PYTHONPATH` to fix this.
I suggest that you use an absolute path in ProgramArguments, so

    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
    &lt;string&gt;python&lt;/string&gt;


would become

    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
    &lt;string&gt;/usr/local/bin/python3&lt;/string&gt;
    ..........


Your PATH variable is not correct. Change it to

    &lt;key&gt;PATH&lt;/key&gt;
    &lt;string&gt;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin&lt;/string&gt;