Помогите решить ошибку python

Abdudelov

Новичок
Автор темы
3
0
В шапке
Надо чтобы pyautogui нашёл изображение нажал по нему сначала правой кнопкой мыши, потом левой
Код в котором у меня ошибка
Code:
import pyautogui as pg
import pydirectinput as pd
import time

ax,ay = pg.locateCenterOnScreen('firefox.PNG',confidence=.6)

def function_when_restart():
    print(ax,ay)
    pd.click(ax,ay)
    print('Waiting to return back to the server...')
    time.sleep(8)
    pd.moveTo(892,531)
    print('finding server...')
    pd.click()
    print('connecting to the server...')

function_when_restart()

Ошибка которую выдает

Error:
D:\PycharmProjects\pythonProject\firefox\venv\Scripts\python.exe D:/PycharmProjects/pythonProject/firefox/main.py
Traceback (most recent call last):
  File "D:\PycharmProjects\pythonProject\firefox\main.py", line 5, in <module>
    ax,ay = pg.locateCenterOnScreen('firefox.PNG',confidence=.6)
  File "D:\PycharmProjects\pythonProject\firefox\venv\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper
    return wrappedFunction(*args, **kwargs)
  File "D:\PycharmProjects\pythonProject\firefox\venv\lib\site-packages\pyautogui\__init__.py", line 207, in locateCenterOnScreen
    return pyscreeze.locateCenterOnScreen(*args, **kwargs)
  File "D:\PycharmProjects\pythonProject\firefox\venv\lib\site-packages\pyscreeze\__init__.py", line 413, in locateCenterOnScreen
    coords = locateOnScreen(image, **kwargs)
  File "D:\PycharmProjects\pythonProject\firefox\venv\lib\site-packages\pyscreeze\__init__.py", line 372, in locateOnScreen
    screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here.
  File "D:\PycharmProjects\pythonProject\firefox\venv\lib\site-packages\pyscreeze\__init__.py", line 144, in wrapper
    raise PyScreezeException('The Pillow package is required to use this function.')
pyscreeze.PyScreezeException: The Pillow package is required to use this function.

Process finished with exit code 1
 

HarukiHack

Новичок
11
0
pip install Pillow ---> import Pillow
 

Вложения

  • Screenshot_35.png
    Screenshot_35.png
    4.1 KB · Просмотры: 69

Qsany

Потрачен
464
147
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Python:
import pyautogui as pg
import pydirectinput as pd
import time

ax,ay = pg.locateCenterOnScreen('firefox.PNG',confidence=.6)

def function_when_restart():
    print(ax,ay)
    pd.rightClick(ax,ay)
    pd.leftClick(ax,ay)
    print('Waiting to return back to the server...')
    time.sleep(8)
    pd.moveTo(892,531)
    print('finding server...')
    pd.click()
    print('connecting to the server...')

function_when_restart()