For Windows users, WeasyPrint requires native system libraries (Cairo, Pango) that are not available by default. The recommended way to install them is via MSYS2.
Download and install MSYS2 from https://www.msys2.org/, then follow the first-time setup instructions on the site.
Open the MSYS2 UCRT64 terminal (search for "MSYS2 UCRT64" in the Start menu) and run:
pacman -S mingw-w64-ucrt-x86_64-pangoAdd the MSYS2 UCRT64 bin directory to your Windows PATH environment variable:
C:\msys64\ucrt64\bin
To do this permanently:
- Open System Properties → Advanced → Environment Variables
- Under System variables, select
Pathand click Edit - Click New and add
C:\msys64\ucrt64\bin - Click OK to save
Open a new Command Prompt or PowerShell window (so the updated PATH takes effect), then reactivate your virtual environment:
.\.venv\Scripts\activatepython -c "from weasyprint import HTML; print('OK')"If you see OK, WeasyPrint is working correctly and you can proceed with installing the remaining dependencies.
Note: If MSYS2 was installed to a different directory (not
C:\msys64), adjust the path in step 3 accordingly.