I'm new to python, and I'm using python 3.10.1. Below is a snippet of the program I am trying to run.
from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
while 1:
if pyautogui.locateOnScreen ('stickman.png'):
print ( " I Can see It " )
time.sleep (0.5)
else:
print ( " I Can't see it " )
time.sleep (0.5)
Here is the error when I run the program:
File "C:/Users/menne/AppData/Local/Programs/Python/Python310/aa.py", line 9, in <module>
if pyautogui.locateOnScreen ('stickman.png'):
File "C:\Users\menne\AppData\Local\Programs\Python\Python310\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File "C:\Users\menne\AppData\Local\Programs\Python\Python310\lib\site-packages\pyautogui\__init__.py", line 213, in locateOnScreen
return pyscreeze.locateOnScreen(*args, **kwargs)
File "C:\Users\menne\AppData\Local\Programs\Python\Python310\lib\site-packages\pyscreeze\__init__.py", line 373, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File "C:\Users\menne\AppData\Local\Programs\Python\Python310\lib\site-packages\pyscreeze\__init__.py", line 353, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
File "C:\Users\menne\AppData\Local\Programs\Python\Python310\lib\site-packages\pyscreeze\__init__.py", line 207, in _locateAll_opencv
needleImage = _load_cv2(needleImage, grayscale)
File "C:\Users\menne\AppData\Local\Programs\Python\Python310\lib\site-packages\pyscreeze\__init__.py", line 170, in _load_cv2
raise IOError("Failed to read %s because file is missing, "
OSError: Failed to read stickman.png because file is missing, has improper permissions, or is an unsupported or invalid format
Why am I receiving this error message?
from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32con
while 1:
if pyautogui.locateOnScreen('stickman.png') == None:
print("I can't see it")
time.sleep(0.5)
else:
print("I am able to see it")
time.sleep(0.5)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.