Python 3 pyAutoGUI – I can't use screenshot functions
Question:
I tried an import from the documentation:
import pyautgui
pyautogui.click(pyautogui.locateOnScreen("select.png"))
and I get these errors in line 2:
File "C:logWinPython-64bit-3.5.4.0Qt5python-3.5.4.amd64libsite-packagespyscreeze__init__.py", line 267, 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:logWinPython-64bit-3.5.4.0Qt5python-3.5.4.amd64libsite-packagespyscreeze__init__.py", line 314, in _screenshot_win32
im = ImageGrab.grab()
NameError: name 'ImageGrab' is not defined
Could you help?
Answers:
Looks like you need to import ImageGrab
from PIL import ImageGrab
i thinhk you need to update pillow
pip in
I tried an import from the documentation:
import pyautgui
pyautogui.click(pyautogui.locateOnScreen("select.png"))
and I get these errors in line 2:
File "C:logWinPython-64bit-3.5.4.0Qt5python-3.5.4.amd64libsite-packagespyscreeze__init__.py", line 267, 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:logWinPython-64bit-3.5.4.0Qt5python-3.5.4.amd64libsite-packagespyscreeze__init__.py", line 314, in _screenshot_win32
im = ImageGrab.grab()
NameError: name 'ImageGrab' is not defined
Could you help?
Looks like you need to import ImageGrab
from PIL import ImageGrab
i thinhk you need to update pillow
pip in