简体   繁体   中英

Python 3 pyAutoGUI - I can't use screenshot functions

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:\log\WinPython-64bit-3.5.4.0Qt5\python-3.5.4.amd64\lib\site-packages\pyscreeze\__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:\log\WinPython-64bit-3.5.4.0Qt5\python-3.5.4.amd64\lib\site-packages\pyscreeze\__init__.py", line 314, in _screenshot_win32
im = ImageGrab.grab()

NameError: name 'ImageGrab' is not defined

Could you help?

看起来您需要导入ImageGrab

from PIL import ImageGrab

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM