需要枕头包,但我已经有了最新版本

Pillow package is required but i already have the latest version

所以我正在尝试将 pyautogui 用于网络抓取工具,但我遇到了这个异常:

"The Pillow package is required to use this function"

我已经有最新版本的 Pillow

代码如下:

import pyautogui

pyautogui.sleep(3)

pyautogui.press('win')
pyautogui.typewrite('google')
pyautogui.press('enter')
pyautogui.sleep(2)
pyautogui.typewrite('youtube.com')
pyautogui.press('enter')

coords = pyautogui.locateCenterOnScreen('new_tab.png')
pyautogui.click(coords)

这是生成错误的行:

coords = pyautogui.locateCenterOnScreen('new_tab.png')

注意:我正在使用: Windows 10 Python 3.9.0 VSCode

您可以在代码开头导入 Pillow:

import PIL

所以我真的想通了!基本上,我必须将 PIL 包移动到站点包,重新启动 VSCode,然后 import PIL 现在它可以工作了!