0

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?

1

1 Answer 1

1

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

1
  • If launchd isn't aware of the PATH variable, how does it know the path to the "default" python - /usr/bin/python
    – fd0
    Aug 20, 2020 at 21:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .