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 ImageGrabdef grab_image(addr): im = ImageGrab.grab() im.save(addr,"jpeg")if __name__ == "__main__": grab_image("test.jpeg")
新闻热点
疑难解答