Domanda

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.

È stato utile?

Soluzione

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"])
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top