Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting AttributeError: module 'pyscreeze' has no attribute 'locateOnWindow' on import #598

Open
S-W-H opened this issue Jul 8, 2021 · 15 comments

Comments

@S-W-H
Copy link

S-W-H commented Jul 8, 2021

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.

@nostep79
Copy link

nostep79 commented Jul 9, 2021

you are not the only one. We updated to this release yesterday and it caused all our testing to fail.

@Zaedus
Copy link

Zaedus commented Jul 12, 2021

Same here. It says this line is the problem

locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__

And throws the same error.

@todoascoding
Copy link

@S-W-H @nostep79 @Zaedus
I've tested it and found out why.

Change your username to alphabet.

@Zaedus
Copy link

Zaedus commented Jul 15, 2021

@S-W-H @nostep79 @Zaedus
I've tested it and found out why.

Change your username to alphabet.

I'm not sure what you mean? I should change my system user name to alphabet? That doesn't really seem like a practical fix.

@todoascoding
Copy link

todoascoding commented Jul 15, 2021

I'm not sure what you mean? I should change my system user name to alphabet? That doesn't really seem like a practical fix.

Doesn't it work the solution for you?
It seems like a Unicode folder issue.

I've got the same error message when my system user name isn't in English. If it is, it works fine.

Anyway, how about make a new account and try it.
You need only 5 mins to do it.

@XDDudeGuy
Copy link

> I've got the same error message when my system user name isn't in English. If it is, it works fine.
I've got the same error and my username only consists of English letters so Idk.

@nanpuhaha
Copy link

I've got the same error. I call the pyautogui.locateOnScreen function, but result is the error below.

AttributeError: module 'pyscreeze' has no attribute 'locateOnWindow'.

There is NO locateOnWindow function on pyscreeze, but pyscreeze.locateOnWindow is used on pyautogui.locateOnWindow.
I think this is the reason.

return pyscreeze.locateOnWindow(*args, **kwargs)

https://github.com/asweigart/pyscreeze/blob/0446e87235e0079f591f0c49ece7d487dedc2f9a/pyscreeze/__init__.py#L350

@JayRizzo
Copy link
Contributor

Hi Everyone! I hope everyone is doing well. It looks like there is an easy fix for this one.

locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__

Here on this line we just need to change

locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__

To This:

locateOnWindow.__doc__ = pyscreeze.locateOnScreen.__doc__

Update this and your inputs will work. The locateOnWindow changed to locateOnScreen.

++@asweigart, FYI

Tested on: Windows Version	10.0.19042 Build 19042
Current Python:        3.9.2
Current PyAutoGUI:     0.9.53

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 folders

@Zaedus
Copy link

Zaedus commented Jul 19, 2021

Thank you! By any chance, has this already been submitted as a PR or already in the works to be modified directly on the main branch?

@S-W-H
Copy link
Author

S-W-H commented Jul 20, 2021

@JayRizzo : Thanks a lot for the proposed solution. But, as addressed by @nanpuhaha, isn't the problem somewhat deeper if there is no locateOnWindow function in pyscreeze?

I mean, pyautogui is already importing locateOnScreen, including its docstring, from pyscreeze under its actual name here:

@raisePyAutoGUIImageNotFoundException
def locateOnScreen(*args, **kwargs):
return pyscreeze.locateOnScreen(*args, **kwargs)
locateOnScreen.__doc__ = pyscreeze.locateOnScreen.__doc__

Thus, I guess we do not need to import the locateOnScreen docstring again under a different name…? Here is some more context in the form of all of the lines dealing with the attempted import of locateOnWindow from pyscreeze. (These follow immediately after the above import of locateOnScreen.)

@raisePyAutoGUIImageNotFoundException
def locateOnWindow(*args, **kwargs):
return pyscreeze.locateOnWindow(*args, **kwargs)
locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__

What I did to fix the issue for the time being was simply to comment out those five lines 217-221. So far, it also works.

@Zaedus : I can't find any current pull request dealing with this. But I also find it hard to submit one without knowing what was the intention of @asweigart for the locateOnWindow function.

@hhslepicka
Copy link

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.

@Be4th
Copy link

Be4th commented Sep 1, 2021

Hi Everyone! I hope everyone is doing well. It looks like there is an easy fix for this one.

locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__

Here on this line we just need to change

locateOnWindow.__doc__ = pyscreeze.locateOnWindow.__doc__

To This:

locateOnWindow.__doc__ = pyscreeze.locateOnScreen.__doc__

Update this and your inputs will work. The locateOnWindow changed to locateOnScreen.

++@asweigart, FYI

Tested on: Windows Version	10.0.19042 Build 19042
Current Python:        3.9.2
Current PyAutoGUI:     0.9.53

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 folders
Man thankyou so much

@abuzze
Copy link

abuzze commented Mar 3, 2022

You should update pyscreeze to at least 0.1.28. to fix this error.

pip3 install pyscreeze -U

@jpmoraes
Copy link

Excellent answer. Then I just have to give a pip install flask

@avinash7903
Copy link

locateOnWindow.doc = pyscreeze.locateOnScreen.doc

thank you for your support it helps me to solve my problem

damies13 added a commit to damies13/rfswarm that referenced this issue May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests