I'm new to coding. I have developed an AppleScript which need to call a python file. i.e autorun.py the Autorun.py start with
import msoffcrypto import pathlib import os ....
Both AppleScript and the python file run fine. even I tried to call autorun.py in terminal also runs 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 codes 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
Any help would be appreciated
CodePudding user response:
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