运行 时,crontab 在 MacOS 上出现 python 导入错误
crontab has python Import Error on MacOS when running
我的完整代码是
import webbrowser
import pyautogui
APCS = "my APCS zoom link here"
webbrowser.open_new_tab(APCS)
print("running!!!!")
crontab 条目是 * * * * * cd Desktop/pp && /usr/bin/python a.py >> a.out 2>&1
crontab 运行在没有import pyautogui
的时候就可以了。否则,在 a.out
它显示我
Traceback (most recent call last):
File "a.py", line 2, in <module>
import pyautogui
ImportError: No module named pyautogui
但是当我从命令行 运行 它时它有效,我肯定有 pyautogui。
您需要使用 python 解释器以获得正确的版本,python3
用于 python 3.x
我的完整代码是
import webbrowser
import pyautogui
APCS = "my APCS zoom link here"
webbrowser.open_new_tab(APCS)
print("running!!!!")
crontab 条目是 * * * * * cd Desktop/pp && /usr/bin/python a.py >> a.out 2>&1
crontab 运行在没有import pyautogui
的时候就可以了。否则,在 a.out
它显示我
Traceback (most recent call last):
File "a.py", line 2, in <module>
import pyautogui
ImportError: No module named pyautogui
但是当我从命令行 运行 它时它有效,我肯定有 pyautogui。
您需要使用 python 解释器以获得正确的版本,python3
用于 python 3.x