Python PyAutoGui-屏幕捕获:无法将文件写入预期目标
我试图在我的屏幕上找到一个图像,但它似乎甚至不能保存截图?有什么想法吗 代码:Python PyAutoGui-屏幕捕获:无法将文件写入预期目标,python,pyautogui,Python,Pyautogui,我试图在我的屏幕上找到一个图像,但它似乎甚至不能保存截图?有什么想法吗 代码: screencapture: cannot write file to intended destination, .screenshot2018-1106_00-06-22-111441.png Traceback (most recent call last): File "/Users/dirk/Desktop/firsttry/test.py", line 103, in <module>
screencapture: cannot write file to intended destination, .screenshot2018-1106_00-06-22-111441.png
Traceback (most recent call last):
File "/Users/dirk/Desktop/firsttry/test.py", line 103, in <module>
a = pyautogui.locateOnScreen('images/toolbox.jpg')
File "/Users/dirk/Library/Python/2.7/lib/python/site-packages/pyscreeze/__init__.py", line 265, in locateOnScreen
screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
File "/Users/dirk/Library/Python/2.7/lib/python/site-packages/pyscreeze/__init__.py", line 331, in _screenshot_osx
im = Image.open(tmpFilename)
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 2609, in open
fp = builtins.open(filename, "rb")
IOError: [Errno 2] No such file or directory: '.screenshot2018-1106_00-06-22-111441.png'
[Finished in 0.8s with exit code 1]
[shell_cmd: python -u "/Users/dirk/Desktop/firstry/test.py"]
[dir: /Users/dirk/Desktop/firsttry]
[path: /opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:~/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
pyautogui.locateOnScreen('images/toolbox.jpg')
错误:
screencapture: cannot write file to intended destination, .screenshot2018-1106_00-06-22-111441.png
Traceback (most recent call last):
File "/Users/dirk/Desktop/firsttry/test.py", line 103, in <module>
a = pyautogui.locateOnScreen('images/toolbox.jpg')
File "/Users/dirk/Library/Python/2.7/lib/python/site-packages/pyscreeze/__init__.py", line 265, in locateOnScreen
screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
File "/Users/dirk/Library/Python/2.7/lib/python/site-packages/pyscreeze/__init__.py", line 331, in _screenshot_osx
im = Image.open(tmpFilename)
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 2609, in open
fp = builtins.open(filename, "rb")
IOError: [Errno 2] No such file or directory: '.screenshot2018-1106_00-06-22-111441.png'
[Finished in 0.8s with exit code 1]
[shell_cmd: python -u "/Users/dirk/Desktop/firstry/test.py"]
[dir: /Users/dirk/Desktop/firsttry]
[path: /opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:~/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
screenscapture:无法将文件写入预期目标,.screenshot2018-1106_00-06-22-111441.png
回溯(最近一次呼叫最后一次):
文件“/Users/dirk/Desktop/firsttry/test.py”,第103行,在
a=pyautogui.locateOnScreen('images/toolbox.jpg')
文件“/Users/dirk/Library/Python/2.7/lib/Python/site-packages/pyscreeze/_-init___u;.py”,第265行,在屏幕上的位置
screenshotIm=screenshot(region=None)#locateAll()函数必须处理裁剪以返回准确的坐标,因此不要在此处传递区域。
osx屏幕截图中第331行的文件“/Users/dirk/Library/Python/2.7/lib/Python/site packages/pyscreeze/_init__.py”
im=Image.open(tmpFilename)
文件“/Library/Python/2.7/site packages/PIL/Image.py”,第2609行,打开
fp=内置的.open(文件名为“rb”)
IOError:[Errno 2]没有这样的文件或目录:'.screenshot2018-1106_00-06-22-111441.png'
[在0.8秒内完成,退出代码为1]
[shell_cmd:python-u”/Users/dirk/Desktop/firstry/test.py“]
[dir:/Users/dirk/Desktop/firsttry]
[路径:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:~/.composer/vendor/bin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin]
- 转到pyscreeze/\uuuu init\uuuu.py(位于virutalenv或python文件夹中)文件,例如:“/Users/dirk/Library/python/2.7/lib/python/site packages/pyscreeze/\uu init\uuuu.py”
- 导航到第327行或第331行,内部函数:def\u屏幕截图\u osx
- 删除tempFilename='.screenshot%s.png'中的符号,使其看起来像tempFilename='screenshot%s.png'
屏幕截图%s.png
前面包含/users/myuser/documents/