LaunchAgents runs Python script in version 2

Maybe someone can explain this. I'm having LaunchAgents run a Python script on startup. The relevant part of the plist looks like:

<key>ProgramArguments</key>
<array>
    <string>python</string>
    <string>/Volumes/path to script

This launches the script in python2, despite the fact that "python" points to python3:

/usr/local/bin/python -> /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8

…which errors because launchd is running a python3 script in python2. To fix it I had to specify python3:

<key>ProgramArguments</key>
<array>
    <string>python3</string>
    <string>/Volumes/

Am I doing this right? Is python2 coded into launchd somewhere? Is there a reason I still need to specify python3?


As mentioned in the comments, you can use full paths in the XML, e.g.:

<string>/usr/local/bin/python</string>

launchd isn't aware of environmental variables, like $PATH, unless explicitly set in the XML, so python would default to /usr/bin/python.

https://serverfault.com/questions/111391/use-an-environment-variable-in-a-launchd-script