I have the applescript which will displays menu list and allow user to select menu items etc. It runs fine by itself. And now I try to run it in python. I get the No user i
My issue was an app with LSBackgroundOnly = YES
set attempting to run an AppleScript that displays UI, such as display dialog ...
Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"
AppleScript.scpt: execution error: No user interaction allowed. (-1713)
Using tell application "Finder" ...
or etc. works, as shown in the other answer.
Or, remove the LSBackgroundOnly
key to enable UI AppleScripts without telling a different Application.
LSUIElement
presents a similar mode - no dock icon, no menu bar, etc. - but DOES allow UI AppleScripts to be launched.
That's a common mistake. When you run a script using OSAScript from a shell, as you are doing, then you must tell an application to show any "display dialogs" or "choose list dialogs" or anything that requires user interaction. OSAScript can't show them so tell an app like the Finder to show them. Use code like this...
tell application "Finder"
activate
display dialog "Now it works!"
end tell
Or from the command line notice this won't work...
osascript -e 'display dialog "Now it will not work."'
But this will work since we tell the Finder to do it...
osascript -e 'tell application "Finder"' -e 'activate' -e 'display dialog "Now it works!"' -e 'end tell'
So bottom line is that somewhere in your iTune.scpt you are displaying a dialog. In that script just tell iTunes or the Finder to display them.