Mac安装PIL模块

  • 执行命令:
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")

     

     
posted @ 2016-05-30 11:27  JohnRey  阅读(8080)  评论(0编辑  收藏  举报