문제

I try to open the calculator application with my Python Shell, but it says permission denied here is the final line of what comes out

"PermissionError: [Errno 13] Permission denied"

    import subprocess
    subprocess.call('/Applications/Calculator.app')

I am doing this on a mac, so anyone with a mac should have this application.

도움이 되었습니까?

해결책

Because is not an executable file. To run the MacOS desktop application you have to run the executable from inside of the Application package.

In case of calculator run try this:

import subprocess
subprocess.call('/Applications/Calculator.app/Contents/MacOS/Calculator')

If you want to run any application without digging around for the executable file in the package (it is not always the same name as the app), use this:

subprocess.call(["/bin/bash","-c","open /Applications/Calculator.app"])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top