WeasyPrint 0.42 depends on:

Python, cairo, Pango and GDK-PixBuf need to be installed separately. See platform-specific instructions for Linux, macOS and Windows below.

Install WeasyPrint with pip. This will automatically install most of dependencies. You probably need either virtualenv (recommended) or using sudo.

virtualenv ./venv
. ./venv/bin/activate
pip install WeasyPrint

Now let’s try it:

weasyprint --help
weasyprint ./weasyprint-website.pdf

You should see warnings about unsupported CSS 3 stuff; this is expected. In the PDF you should see the WeasyPrint logo on the first page.

You can also play with WeasyPrint Navigator or WeasyPrint Renderer. Start it with

python -m


python -m

and open your browser at

If everything goes well, you’re ready to start using WeasyPrint! Otherwise, please copy the full error message and report the problem.

[1]cairo ≥ 1.15.4 is best but older versions may work too. The test suite passes on cairo 1.14, and passes with some tests marked as “expected failures” on 1.10 and 1.12 due to behavior changes or bugs in cairo. If you get incomplete SVG renderings, please read #339. If you get invalid PDF files, please read #565.
[2]pango ≥ 1.29.3 is required, but 1.38.0 is needed to handle @font-face CSS rules.
[3]Without it, PNG and SVG are the only supported image formats. JPEG, GIF and others are not available.


Pango, GdkPixbuf, and cairo can not be installed with pip and need to be installed from your platform’s packages. CFFI can, but you’d still need their own dependencies. This section lists system packages for CFFI when available, the dependencies otherwise. CFFI needs libffi with development files. On Debian, the package is called libffi-dev.

If your favorite system is not listed here but you know the package names, tell us so we can add it here.

Debian / Ubuntu

Debian 9.0 Stretch or newer, Ubuntu 16.04 Xenial or newer:

sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info


WeasyPrint is packaged for Fedora, but you can install it with pip after installing the following packages:

sudo yum install redhat-rpm-config python-devel python-pip python-setuptools python-wheel python-cffi libffi-devel cairo pango gdk-pixbuf2


WeasyPrint is available in the AUR, but you can install it with pip after installing the following packages:

sudo pacman -S python-pip python-setuptools python-wheel cairo pango gdk-pixbuf2 libffi pkg-config


WeasyPrint is packaged in Gentoo, but you can install it with pip after installing the following packages:

emerge pip setuptools wheel cairo pango gdk-pixbuf cffi


WeasyPrint is automatically installed and tested on virtual macOS machines. The official installation method relies on Homebrew:

brew install python3 cairo pango gdk-pixbuf libffi

Don’t forget to use the pip3 command to install WeasyPrint, as pip may be using the version of Python installed with macOS.

You can also try with Macports, but please notice that this solution is not tested and thus not recommended (also known as “you’re on your own and may end up crying blood with sad dolphins for eternity”):

sudo port install py-pip cairo pango gdk-pixbuf2 libffi


Dear Windows user, please follow these steps carefully.

Really carefully. Don’t cheat.

If you decide to install Python or GTK 32 bit on Windows 64 bit, you’re on your own, don’t even try to report an issue, kittens will die because of you.

If you get an error like OSError: dlopen() failed to load a library: cairo / cairo-2 it’s because Cairo (or the library given in your error) is not available in one of the folders listed in your PATH environment variable. Reinstalling GTK (and carefully reading the warnings above) will probably solve your problem. You can also find extra help in this bug report.