首页 > 解决方案 > Python 给了我很多回溯的东西是怎么回事

问题描述

这是我的代码

from pyautogui import * 
import pyautogui 
import time 
import keyboard 
import random
import win32api, win32con

while (1):
    if pyautogui.locateOnScreen('stickman.png', region=(150,175,350,600), grayscale=True, confidence=0.8) != None:
        print("I can see it")
        time.sleep(0.5)
else:
    print("I am unable to see it")
    time.sleep(0.5)

追溯:

Traceback (most recent call last):
  File "C:\Users\TheJa\OneDrive\Desktop\test.py", line 9, in <module>
    if pyautogui.locateOnScreen('stickman.png', region=(150,175,350,600), grayscale=True, confidence=0.8) != None:
  File "C:\Users\TheJa\AppData\Local\Programs\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper
    return wrappedFunction(*args, **kwargs)
  File "C:\Users\TheJa\AppData\Local\Programs\Python\Python39\lib\site-packages\pyautogui\__init__.py", line 213, in locateOnScreen
    return pyscreeze.locateOnScreen(*args, **kwargs)
  File "C:\Users\TheJa\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 359, in locateOnScreen
    screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
  File "C:\Users\TheJa\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 134, in wrapper
    raise PyScreezeException('The Pillow package is required to use this function.')
pyscreeze.PyScreezeException: The Pillow package is required to use this function.

标签: pythonpython-imaging-library

解决方案


推荐阅读