Applescript在尝试通过python scrip打开png文件时给出错误权限被拒绝

2024-10-05 15:27:14 发布

您现在位置:Python中文网/ 问答频道 /正文

你好,所以我做了一个脚本,采取了一个截图,然后从截图中读取所有的python文本,它的作品很好。然而,我试图让脚本从Applescript运行,我得到一个错误。你知道吗

我试过使用“shell”,但是它不起作用。你知道吗

这是python脚本的一部分:

im = ImageGrab.grab(bbox=(100,200,1250,700))
im.save('duolingo.png')

pytesseract.pytesseract.tesseract_cmd = r'/usr/local/Cellar/tesseract/4.0.0_1/bin/tesseract'

x = pytesseract.image_to_string(Image.open('duolingo.png'))

还有Applescript:

do shell script "/usr/local/bin/python3 /Users/user/Documents/duolingobot.py $@"

这是我的错误:

error "Traceback (most recent call last):
  File \"/Users/user/Documents/duolingobot.py\", line 11, in <module>
    im.save('duolingo.png')
  File \"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PIL/Image.py\", line 2004, in save
    fp = builtins.open(filename, \"w+b\")
PermissionError: [Errno 13] Permission denied: 'duolingo.png'" number 1

Tags: pyimage脚本binpngsaveusrlocal