Python – Install WeasyPrint on a linux (Webfaction) server

WeasyPrint is a great python library to generate PDFs from HTML. It beats hands down xhtml2pdf, by interpreting CSS and HTML the right way.

However, it has a lot of dependencies and it just can’t fit in a simple python virtual environment. It took me a whole day to install on Webfaction, so I think it would be helpful to show how to do it properly.

These steps has been tested on a Webfaction CentOS 6 server (python2.7), and they should be the same for others Linux systems. If your system is not exactly the same, you might have to install other dependencies manually. Linux From Scratch is your helpful friend in this kind of situation.