Mac安装PIL模块

Posted JohnRey

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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")

     

     

以上是关于Mac安装PIL模块的主要内容,如果未能解决你的问题,请参考以下文章

windows开发环境下python中的PIL包如何安装

Mac系统下安装PIL

mac上安装pil报错: ERROR: Could not find a version that satisfies the requirement pil (from versions: non

如何在 mac os x 10.7.2 Lion 上安装 PIL

如何在pycharm中安装PIL模块

如何在pycharm中安装PIL模块