Reputation: 8548
I'm creating a script to find image on the screen, my code is like this:
import pyautogui
image = pyautogui.locateOnScreen('my-image.png')
print(image)
The image is a print screen, so the scale of the image is the same.
When the image is not on the screen, my script is printing None
, but when the image is on the screen, it's returning an error like this:
$ python index.py
Traceback (most recent call last):
File "C:\Projects\project\lib\site-packages\pyscreeze\__init__.py", line 234, in _locateAll_python
raise StopIteration()
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "index.py", line 3, in <module>
image= pyautogui.locateOnScreen('my-image.png')
File "C:\Projects\project\lib\site-packages\pyscreeze\__init__.py", line 266, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File "C:\Projects\project\lib\site-packages\pyscreeze\__init__.py", line 250, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
RuntimeError: generator raised StopIteration
What it's wrong in my code? I'm using Windows 10 x64.
Upvotes: 0
Views: 731
Reputation: 280837
It's not a problem with your code. The pyscreeze
maintainers need to update their code to use return
instead of raise StopIteration()
to end their generators, as PEP 479 has been enabled for all code in Python 3.7, changing the behavior of StopIteration
in a generator.
Upvotes: 3