ponty / pyscreenshot

Python screenshot library, replacement for the Pillow ImageGrab module on Linux.
BSD 2-Clause "Simplified" License
502 stars 88 forks source link

import PIL, ModuleNotFoundError #70

Closed BastienH closed 3 years ago

BastienH commented 4 years ago

Hi, I ran into a basic issue when running pyscreenshot for the first time. I found a sample code here :

import pyscreenshot as ImageGrab
im = ImageGrab.grab()
im.save('path/to/image/folder/image_name.png')
im.show()

quite simple. But it didn't work. apparently PIL is deprecated in favor of pillow.

To solve it, I just changed the first line in the init to:

try:
    from PIL import Image
except ModuleNotFoundError:
    from pillow import Image

Maybe this can be shipped in the next version? I haven't seen that this question had history already...

Anyway thanks for this package, works great!

ponty commented 4 years ago

How did you install Pillow? Pillow use PIL for import, check the doc: https://pillow.readthedocs.io/en/stable/handbook/tutorial.html#using-the-image-class

>>> from PIL import Image