0004
0004

Reputation: 1260

PyAutoGUI - No Such File or Directory Error

Anyone have any luck on this ? I am tyring to recreate this [tutorial code][1] :

>>> import pyautogui
>>> button7location = pyautogui.locateOnScreen('calc7key.png')
>>> button7location
(1416, 562, 50, 41)
>>> button7x, button7y = pyautogui.center(button7location)
>>> button7x, button7y
(1441, 582)
>>> pyautogui.click(button7x, button7y)

But I get the following error [at line 2 of the code above] FileNotFoundError: [Errno 2] No such file or directory: 'calc7key.PNG' when I have such file stored in File "C:\Users*******\Desktop\Python\lib\site-packages\pyscreeze__init__.py", line 165, in _locateAll_python needleFileObj = open(needleImage, 'rb') FileNotFoundError: [Errno 2] No such file or directory: 'calc7key.PNG' ..anyone have any luck using this. essentially I am trying to screenshot a minimized tab to be opened by pyautogui (like lets say the google chrome icon at the bottom of my screen)

Upvotes: 1

Views: 4179

Answers (2)

Amorim Furtado
Amorim Furtado

Reputation: 16

for me worked installing open cv: pip install opencv-python

(https://pypi.org/project/opencv-python/)

showing recommendation to install openCV enter image description here

Upvotes: 0

0004
0004

Reputation: 1260

Solved : Had to change to the directory it was in

>>> import os
>>> os.chdir (r'C:\******')
>>>button7location = pyautogui.locateOnScreen('calc7key.png')

Upvotes: 3

Related Questions