Skip to content

Instantly share code, notes, and snippets.

@IgorKurkov
Forked from doobeh/gist:3188318
Created April 2, 2021 10:22
Show Gist options
  • Save IgorKurkov/afdb472b467777a7bda70013c3a320d7 to your computer and use it in GitHub Desktop.
Save IgorKurkov/afdb472b467777a7bda70013c3a320d7 to your computer and use it in GitHub Desktop.
Installing WeasyPrint on Windows

Installing WeasyPrint on Windows

WeasyPrint converts HTML including images to PDF, it's cross platform but Windows requires a decent amount of massaging to persuade it to work.

To install Pango and Cairo download the all in one bundle of the GTK+ stack and extract the archive to C:\GTK.

You'll need to add the GTK bin folder to your system path so the various libraries can be found when requested by WeasyPrint, to do that go to the 'System' in the Control Panel, then open 'Advanced System Settings' then 'Environment Variables' and edit the System variable called Path by adding ;c:\gtk to the end of the current value.

With that out of the way, we need to install a few Python libraries that WeasyPrint uses to interface with the GTK stack. The easiest way is from precompiled binaries, so head over to Christoph Gohkle's Python Packages and download and install Py2Cairo, PyGObject and PyGTK for your version of Python (I've tested with 32bit 2.7). You'll also need to install the lxml package he provides.

Now you should be able to just pip install WeasyPrint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment