pyautogui, screenshot function doesn't recognize installed Pillow module

Question:

I want to execute this code in Pycharm

x, y = pyautogui.locateCenterOnScreen('LVL35.png')

But I get this message

ImportError: Pillow module must be installed to use screenshot functions on Windows.

The thing is, I use anaconda and Pillow is already installed and I can also find it in the Project Interpreter settings.

Requirement already satisfied: Pillow in c:anaconda3libsite-packages (4.2.1)

Any idea?

enter image description here

Asked By: Svenno Nito

||

Answers:

That’s almost a bit embarassing, but in case anyone of you has the same problem, just update your Pillow package.

pip install Pillow --upgrade

Pillow-4.2.1 was on my system, it upgraded to Pillow-5.1.0 and now everything works just fine.

Answered By: Svenno Nito

In case anyone has this problem and couldn’t fix it with the previous solution regarding the installed version, try uninstalling and installing it back, it worked for me. I checked the version I had (8.0) and the version it installed back was the same, so no changes on the version aspect, but for some reason it was failing with the same error message OP was getting and now it isn’t.

  • Windows 10
  • Anaconda 1.9.12
  • PyAutoGui 0.9.52
  • Pillow 8.0
Answered By: Kaladin

If you are installing it using pip, then it will cause the mentioned issue at it imports an older version of Pillow.
You can either upgrade the version using pip upgrade --Pillow
or
you can directly install pyautogui directly from PyCharm project settings. Follow the following steps:

File -> Settings -> Project name -> Python Interpreter -> + -> Type pyautogui -> Install Package

Answered By: Hassan Shahzad

I had the same problem. The solution I found was that old maxim in the "Restart the tool" area. In my case I was using PyCharm.

Answered By: KingStonne's

You can use the pyscreeze module

import pyscreeze
x, y = pyscreeze.locateCenterOnScreen('LVL35.png')

Thanks

Answered By: Christian Balinda