Форум сайта python.su
Приветствую.
Пробую pyautogui. На простом примере из help'a вылезает море ошибок. Знатоки, подскажите в чем дело.
Пример:
import pyautogui button7location = pyautogui.locateOnScreen('calc7key.png') button7location
C:\Project\Clicker\venv\Scripts\python.exe C:/Project/Clicker/venv/clicker.py Traceback (most recent call last): File "C:\Project\Clicker\venv\clicker.py", line 2, in <module> button7location = pyautogui.locateOnScreen('calc7key.png') File "C:\Project\Clicker\venv\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper return wrappedFunction(*args, **kwargs) File "C:\Project\Clicker\venv\lib\site-packages\pyautogui\__init__.py", line 213, in locateOnScreen return pyscreeze.locateOnScreen(*args, **kwargs) File "C:\Project\Clicker\venv\lib\site-packages\pyscreeze\__init__.py", line 359, in locateOnScreen screenshotIm = screenshot(region=None) # the locateAll() function must handle cropping to return accurate coordinates, so don't pass a region here. File "C:\Project\Clicker\venv\lib\site-packages\pyscreeze\__init__.py", line 134, 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
Офлайн
Установи библиотеку pillow.
https://python-pillow.org/
https://pillow.readthedocs.io/en/stable/installation.html
Офлайн
Поставил, проверил, работает. Спасибо.
Добавил confidence=0.5 и работать перестало. В чем может быть дело?
import pyautogui button7location = pyautogui.locateOnScreen('calc7key.png', confidence=0.5) button7location
C:\Project\Clicker\venv\Scripts\python.exe C:/Project/Clicker/venv/clicker.py Traceback (most recent call last): File "C:\Project\Clicker\venv\lib\site-packages\numpy\__init__.py", line 305, in <module> _win_os_check() File "C:\Project\Clicker\venv\lib\site-packages\numpy\__init__.py", line 302, in _win_os_check raise RuntimeError(msg.format(__file__)) from None RuntimeError: The current Numpy installation ('C:\\Project\\Clicker\\venv\\lib\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/y3dm3h86 Traceback (most recent call last): File "C:\Project\Clicker\venv\clicker.py", line 2, in <module> button7location = pyautogui.locateOnScreen('calc7key.png', confidence=0.5) File "C:\Project\Clicker\venv\lib\site-packages\pyautogui\__init__.py", line 175, in wrapper return wrappedFunction(*args, **kwargs) File "C:\Project\Clicker\venv\lib\site-packages\pyautogui\__init__.py", line 213, in locateOnScreen return pyscreeze.locateOnScreen(*args, **kwargs) File "C:\Project\Clicker\venv\lib\site-packages\pyscreeze\__init__.py", line 360, in locateOnScreen retVal = locate(image, screenshotIm, **kwargs) File "C:\Project\Clicker\venv\lib\site-packages\pyscreeze\__init__.py", line 340, in locate points = tuple(locateAll(needleImage, haystackImage, **kwargs)) File "C:\Project\Clicker\venv\lib\site-packages\pyscreeze\__init__.py", line 135, in wrapper return wrappedFunction(*args, **kwargs) TypeError: _locateAll_python() got an unexpected keyword argument 'confidence' Process finished with exit code 1
Офлайн
Переустанови numpy
pip uninstall numpy
pip install numpy==1.19.3
Офлайн
Спасибо, помогло!
Офлайн