pyautogui: Getting AttributeError: module 'pyscreeze' has no attribute 'locateOnWindow' on import
When attempting import pyautogui
, I get the following error message and traceback:
Traceback (most recent call last):
File "<ipython-input-1-fa2587ca3a04>", line 1, in <module>
import pyautogui
File "/usr/lib/python3.9/site-packages/pyautogui/__init__.py", line 221, in <module>
locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__
AttributeError: module 'pyscreeze' has no attribute 'locateOnWindow'
I have checked the contents of pyscreeze/__init__.py
, not just on my computer, but as it currently appears in the pyscreeze repository as well, and there really is no locateOnWindow
function/class/etc. contained in it.
The problem might have been introduced by this commit about 2-3 months ago. Strangely, however, I have not been able to find anyone else on the web experiencing it.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 9
- Comments: 15 (1 by maintainers)
Commits related to this issue
- pyscreeze 0.1.28 https://github.com/asweigart/pyautogui/issues/598 — committed to damies13/rfswarm by damies13 a year ago
Hi Everyone! I hope everyone is doing well. It looks like there is an easy fix for this one.
https://github.com/asweigart/pyautogui/blob/5e4acb870f2e7ce0ea1927cc5188bc2f5ab7bbbc/pyautogui/__init__.py#L221
Here on this line we just need to change
To This:
Update this and your inputs will work. The
locateOnWindow
changed tolocateOnScreen
.++@asweigart, FYI
The file location for me was: ‘C:\Users\
{UserName}
\AppData\Roaming\Python\Python39\site-packages\pyautogui\init.py’Do not look in the
C:\Program Files\Python39
foldersYou should update pyscreeze to at least 0.1.28. to fix this error.
pip3 install pyscreeze -U
I’ve got the same error. I call the pyautogui.locateOnScreen function, but result is the error below.
There is NO
locateOnWindow
function on pyscreeze, butpyscreeze.locateOnWindow
is used onpyautogui.locateOnWindow
. I think this is the reason.https://github.com/asweigart/pyautogui/blob/5e4acb870f2e7ce0ea1927cc5188bc2f5ab7bbbc/pyautogui/__init__.py#L219
https://github.com/asweigart/pyscreeze/blob/0446e87235e0079f591f0c49ece7d487dedc2f9a/pyscreeze/__init__.py#L350
I run into this problem today and it was due to a newer pyautogui version with old pyscreeze. A less relaxed condition on the dependency (https://github.com/asweigart/pyautogui/blob/master/setup.py#L36) would have avoided it. Upgrading pyscreeze solved the issue for me.