Skip to content

Instantly share code, notes, and snippets.

@doobeh
Created July 27, 2012 14:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save doobeh/3188318 to your computer and use it in GitHub Desktop.
Save doobeh/3188318 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

@MohnishMagesh
Copy link

Once installation is complete, where should I save these files?
Py2Cairo, PyGObject and PyGTK

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