There may be some similar questions like this one, but I didn\'t find any answer for me.
I tried some ways to do it like:
sudo aptitude install python-qt4-
On aws ubuntu (12.04 and 14.04):
sudo apt-get update
sudo apt-get install python-qt4
sudo apt-get install libxml2-dev libxslt1-dev python-dev
sudo apt-get install python-lxml
sudo apt-get install xvfb
Check this link and generate your-own-example.py
DISPLAY=localhost:1.0 xvfb-run python your-own-example.py
Voila.