As long as you probably understood this in the last two years, I had the same problem today. Decision:
import subprocess subprocess.check_call(['xvfb-run', '-s', '-screen 0 1024x768x24', 'CutyCapt', '--url=http://www.google.com/', '--out=google.png'])
or
import subprocess subprocess.check_call(['xvfb-run', '--server-args=-screen 0 1024x768x24', 'CutyCapt', '--url=http://www.google.com/', '--out=google4.png'])
Suppose you have xvfb installed. I use CutyCapt as my sample application, which requires running the X-framebuffer (its a program that converts web kit pages to images and requires an X server).
source share