Question

I am trying to use PIL to get screenshot, but some import error appear when I import ImageGrab from PIL. (Platforms are Mac OS X and Debian)

like,

from PIL import ImageGrab

When I do this, the result is

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/ImageGrab.py", line 34, in <module>
import _grabscreen
ImportError: No module named _grabscreen

This said that there is no module named "_grabscreen".
Is there any way to solve this problem?

Was it helpful?

Solution

Mac OS support has since been added to Pillow ImageGrab, as of version 3.0.0. It uses the same API as on Windows -

from PIL import ImageGrab
im = ImageGrab.grab()  # entire screen
im2 = ImageGrab.grab([0, 0, 100, 100])  # a selected region of the screen

However, there is no Linux support at the moment.

You can read more here - http://pillow.readthedocs.io/en/5.2.x/reference/ImageGrab.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top