weasyprint --info fails with OSError: cannot load library 'libpango-1.0-0' in WSL2 (Ubuntu 24.04) virtual environment
Hi, I encountered an error when running weasyprint --info after installing WeasyPrint in a Python virtual environment on WSL2 (Ubuntu 24.04). The error indicates that the libpango-1.0-0 library cannot be found, even after attempting the troubleshooting steps linked in the error message.
Steps to Reproduce:
Environment: WSL2 with Ubuntu 24.04.
Create a virtual environment: python -m venv venv and activate it.
Install WeasyPrint: pip install weasyprint.
Run the diagnostic command: weasyprint --info.
Expected Result: The command should display system information and available fonts without errors.
Actual Result:
The command fails with the following error:
OSError: cannot load library 'libpango-1.0-0': libpango-1.0-0: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libpango-1.0-0'
when i quit the venv enviroment ,it's works
Hi!
when i quit the venv enviroment ,it's works
Well, your install seems to be a bit messy. 😄 Your virtual environment uses Python 3.11 while outside you use Python 3.12, WeasyPrint is installed both in your virtual environment and on the system, with an old 61.1 version.
Where does the (base) come from at the beginning of your prompt, did you activate another virtual environment before activating venv? Could you try to create venv with the same Python 3.12 version as the one used by your working WeasyPrint 61.1?