Search code examples
pythonweb-scrapingvisual-studio-codepyautogui

Pillow package is required but i already have the latest version


So I'm trying to use pyautogui for a web scraper but I get this exception:

"The Pillow package is required to use this function"

I already have the latest version of Pillow

Here's the code:

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)

Here's the line generating the error:

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

NOTE: I am using: Windows 10 Python 3.9.0 VSCode


Solution

  • So I actually figured it out! Basically, I had to move the PIL package to site-packages, restart VSCode, and import PIL and now it works!