Skip to content

Install needed libraries for Weasyprint on pipenv (Windows environment)

In order to start generating documents with Weasyprint I installed it on my Windows machine following these instructions:

On my computer it works but I have a Django project where I want to integrate this library and I use pipenv.
How to install the necessary libraries even in the virtual environment?
I tried setting the path for the pycairo package into the Pipfile like

pycairo= {path= "C:/Program Files/GTK3-Runtime Win64/bin/"}

but still it throws the error:

OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 /

I have 64bit Windows machine and this is the Pipfile:

name = "pypi"
url = ""
verify_ssl = true
pylint = "*"
django = "*"
mysql = "*"
ipython = "*"
django-webpack = "*"
django-webpack-loader = "*"
django-livereload-server = "*"
pylint = "*"
reportlab = "*"
weasyprint = "*"
django-weasyprint = "*"
pycairo= {path= "C:/Program Files/GTK3-Runtime Win64/bin/"}
cairocffi = "*"
python_version = "3.7"


You need install ‘GTK+ 64 Bit Installer’ path in this local:


Source: WeasyPrint Github