0

I have developed an AppleScript which needs to call a python file. i.e autorun.py the Autorun.py start with

import msoffcrypto
import pathlib
import os
....

Both the AppleScript and the python file run fine. I even tried to call autorun.py in the terminal and that also runs with no problem. But when the Applescript tried to call the python file:

set myPythonScript to POSIX path of "/Users/zhouyu/Library/Application Scripts/com.apple.mail/autounlock.py"

set myVal to do shell script "python" & space & myPythonScript's quoted form

display dialog myVal

It failed at the first line in the python code when Applescript tried to call it.

error "Traceback (most recent call last): File "/Users/zhouyu/Library/Application Scripts/com.apple.mail/autounlock.py", line 2, in import msoffcrypto ImportError: No module named msoffcrypto" number 1

1 Answer 1

1

Unlike Terminal.app, do shell script does not read your shell profile so make sure you give it the full path to your python interpreter, e.g.:

do shell script "/usr/local/bin/python3" & space & myPythonScript's quoted form
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.