WeasyPrint 0.34 depends on:
- CPython 2.7 or ≥ 3.3
- cairo 
- CFFI ≥ 0.6
- lxml ≥ 3.0
- html5lib ≥ 0.999999999
- cairocffi ≥ 0.5
- tinycss ≥ 0.4
- cssselect ≥ 0.6
- CairoSVG ≥ 1.0.20
- Pyphen ≥ 0.8
- Optional: GDK-PixBuf 
Python, cairo, Pango and GDK-PixBuf need to be installed separately. See platform-specific instructions for Linux, OS X and Windows below.
lxml can be installed by pip automatically if your system has a C compiler and the recursive dependencies, but using a system package might be easier.
virtualenv --system-site-packages ./venv . ./venv/bin/activate pip install WeasyPrint
Now let’s try it:
weasyprint --help weasyprint http://weasyprint.org ./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. Start it with
python -m weasyprint.navigator
|||cairo ≥ 1.12 is best but older versions should work too. The test suite passes on cairo 1.8 and 1.10 with some tests marked as “expected failures” due to behavior changes or bugs in cairo.|
|||Without it, PNG and SVG are the only supported image format: JPEG, GIF and others are not available.|
|||Passing the |
Pango, GdkPixbuf, and cairo can not be installed
with pip and need to be installed from your platform’s packages.
lxml and CFFI can, but you’d still need their own dependencies.
This section lists system packages for lxml and CFFI when available,
the dependencies otherwise.
lxml needs libxml2 and libxslt, CFFI needs libffi.
On Debian, the package names with development files are
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 8.0 Jessie or newer, Ubuntu 14.04 Trusty or newer:
sudo apt-get install python-dev python-pip python-lxml python-cffi libcairo2 libpango1.0-0 libgdk-pixbuf2.0-0 shared-mime-info
Debian 7.0 Wheezy or newer, Ubuntu 12.04 Precise or newer:
sudo apt-get install python-dev python-pip python-lxml libcairo2 libpango1.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-lxml 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-lxml cairo pango gdk-pixbuf2 libffi pkg-config
WeasyPrint is automatically installed and tested on virtual MacOS machines. The official installation method relies on Homebrew:
brew install python3 cairo pango gdk-pixbuf libxml2 libxslt 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 py-lxml cairo pango gdk-pixbuf2 libffi
Dear Windows user, please follow these steps carefully.
Really carefully. Don’t cheat.
If you decide to install Python, GTK or lxml 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.
- Install Python 3.5.x
with “Add Python 3.5 to PATH” checked:
- “Windows x86 executable installer” on Windows 32 bit,
- “Windows x86-64 executable installer” on Windows 64 bit,
- install GTK with “Set up PATH environment variable to include GTK+” checked:
- install Visual C++ Build Tools as explained in Python’s wiki,
- download lxml for Windows:
- “lxml-x.x.x-cp35-cp35m-win32.whl” on Windows 32 bit,
- “lxml-x.x.x-cp35-cp35m-win_amd64.whl” on Windows 64 bit,
- install lxml with
python -m pip install path/to/lxml-xxx.whl
- install WeasyPrint with
python -m pip install weasyprint,
- test with
python -m weasyprint http://weasyprint.org weasyprint.pdf.