Ok, so when I run this command:
sudo python3.5 /path/to/my/script.py
- My username
Choose the account that needs cleaning up (enter corresponding number):
osascript -e 'do shell script "python3.5 /Path/to/my/script.py" with administrator privileges'
OSError: [Errno 9] Bad file descriptor (1)needs cleaning up (enter
Ah, so I figured this one out myself. As expected it had to do with privileges. Somehow
"do shell script" is run via other privileges then just entering the command in terminal. And
"sudo command" in terminal does not equal (fully) to
"do shell script [script] with administrator privileges".
For me, what fixed it, was navigating to:
System Preferences --> Security and Privacy --> Privacy tab --> Accessibility
And then dragging Python.app and Terminal.app to that window (you might need to unlock it first by pressing on the little lock in the lower-left corner of that window).