- 执行命令:
sudo easy_install -f http://www.pythonware.com/products/pil/ Imaging
- 如果出现错误,则执行命令xcode-select --install,然后重新进行上一步,具体错误如下:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/tk.h:78:11: fatal error:
'X11/Xlib.h' file not found
# include <X11/Xlib.h>
- 再安装Pillow模块即可:
sudo pip install -U Pillow
- 测试抓取屏幕:
from PIL import ImageGrab def grab_image(addr): im = ImageGrab.grab() im.save(addr,"jpeg") if __name__ == "__main__": grab_image("test.jpeg")