문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top