3
import pyautogui
wh = pyautogui.size()
print(wh)

output:

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

Please I will be grateful for your Help.

Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
Richlue Toure
  • 31
  • 1
  • 3
  • I would make sure that the versions of the libraries you're using are the same as in the book, since sometimes things get deprecated, but of course a book can't be updated to reflect those changes. – Random Davis Jul 12 '21 at 22:55
  • here is the [docs for pyautogui](https://pyautogui.readthedocs.io/en/latest/) it might be that the method is called `locateOnScreen()` – Matiiss Jul 12 '21 at 22:59
  • Thank you Random Davis & Matiiss , It works. – Richlue Toure Jul 13 '21 at 23:44

5 Answers5

4

locatOnWindows method is missing from pyscreeze init.py file, you can get the updated code from link below, just copy and past the code to pyscreeze init.py file and hopefully this issue will be resolved

https://github.com/asweigart/pyscreeze/blob/master/pyscreeze/init.py#L418

Husam Alhwadi
  • 383
  • 3
  • 11
0

I deleted pyautogui and pyscreeze, then it worked for me.

To delete First locate where pyautogui is installed. Use this command to locate pyautogui on your machine:

 pip show pyautogui

Then copy location.

My location was:

c:\users\nitro 5\appdata\local\programs\python\python38\lib\site-packages

Delete Pyautogui and pyscreeze.

Install pyautogui:

pip install pyautogui
0

try to change init.py in C:\Users\User\AppData\Local\Programs\Python\Python310\Lib\site-packages\pyscreeze from github: https://github.com/asweigart/pyscreeze/blob/master/pyscreeze/__init__.py

Bogdan
  • 1
0

I have also had the exact same issue. All that I really had to do was to install the newer version of the Pyscreeze library. As you can see from this link https://github.com/asweigart/pyscreeze/commit/9edb5d70fbe3b3ee2f2cb710f25401b893d51dfc they've added the locateOnWindow() function in the version of 0.1.27. As for my part, I'd had the Pyscreeze of 0.1.26 version. After I'd had installed the newer version of the library everything started working just fine.

Igor Suhotin
  • 41
  • 1
  • 2
  • 5
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 05 '22 at 23:54
0

I had the same problem and solved it with this method

pip install --upgrade pyscreeze 
vimuth
  • 5,064
  • 33
  • 79
  • 116