Here’s what I did to get the export_schematic.py script working on a headless Ubuntu 16.04 minimal VM.
1. sudo apt-get install kicad
2. sudo apt-get install xvfb
3. sudo apt-get install xdotool
4. sudo apt-get install imagemagick
5. Xvfb :0 -screen - 1280x1024x16&
6. export DISPLAY=":0.0"
Additionally, to run the generate_svg.py script that seems to export the PCB file, I had to install Inkscape.
7. sudo apt-get install inkscape
Next step is accepting an arbitrary file to convert. The existing scripts focus on the hardware project the scripts are embedded with.