PDA

Просмотр полной версии : Помогите решить ошибку python


Abdudelov
22.04.2022, 00:23
В шапке

Надо чтобы 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\Scri pts\python.exe D:/PycharmProjects/pythonProject/firefox/main.py
Traceback (most recent call last):
File "D:\PycharmProjects\pythonProject\firefox\main.py", line 5, in
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

Vitalya_
22.04.2022, 13:14
нужен Pillow - pip install Pillow

HarukiHack
22.04.2022, 14:28
pip install Pillow ---> import Pillow

IlyaFontonov
21.01.2023, 11:10
Привет, такая же ошибка, если решил = дай знать

Qsany
24.01.2023, 21:18
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
(
)