Fontconfig error when trying to run WeasyPrint
See original GitHub issueHello,
I am trying to use WeasyPrint for an existing project but sadly, I ran into some issues while installing. I followed the installation guide here: https://weasyprint.readthedocs.io/en/latest/install.html (I used the GTK+ 64bit installer during the installation).
After installation, the test call python -m weasyprint https://google.com weasyprint.pdf
led to the following output: Fontconfig error: Cannot load default config file
. No PDF was generated.
I was not able to find any real information what I could do to fix that.
Windows version: Windows 10 Version 20H2 (OS Build 19042.867)
Output of python --version --version
: Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)]
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Fontconfig error when trying to run WeasyPrint #1339 #1463
It means that you probably have different versions of Pango and/or Harfbuzz and/or FontConfig installed, and that they don't work well ...
Read more >Django weasyPrint fontconfig error - python - Stack Overflow
Then I tried to use from weasyprint import HTML, CSS from weasyprint.fonts import FontConfiguration I still got the same error.
Read more >#2448 (Fontconfig error with cairo on Windows) – GRASS GIS
I can not confirm the error Fontconfig error: Cannot load default config file, but the labels aren't displayed with cairo; it is with...
Read more >Installing — WeasyPrint 52.5 documentation - CourtBouillon
pip3 install WeasyPrint. If you get the Fontconfig error: Cannot load default config file message, then try reinstalling fontconfig:.
Read more >WeasyPrint 43 documentation - GitHub Pages
WeasyPrint ¶. WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF. It aims to support web standards...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I also encountered this problem, it has been bothering me for a long time.I used cmd “WHERE fontconfig.dll”,it was returned “D:\Program Files\Graphviz\bin\fontconfig.dll”,emm…, then I uninstalled Graphviz,weasyPrint was worked well!
Got the error!
First of, why the error changed when I reinstalled GTK3+: When I first installed GTK3+ I moved it to the front of the PATH just to be sure. Reinstalling GTK3+ removed it from my PATH and added it again at the back. Although
WHERE libpango-1.0-0.dll
returns the correct path (and although procmon showed my that python indeed tried to access it) it seems like python used some other version of that DLL. Moving it back to the front helped.Now to the original problem: Since it worked well with the other problem, I used procmon again to watch for every access to some path containing “fontconfig”. Turns out python again loads the wrong DLL. The problem was that GTK may be at the front of my path, but since
dlopen
tries out one possible DLL name after the other and the correct for my system is at place 3, it loads the wrong DLL if one of the first two variants is present somewhere on my PATH. For another project I have graphviz installed, and graphviz comes with a DLL calledfontconfig.dll
which is on place 1.Thanks for your help and special thanks to @Tontyna, your comment brought me to the right track.
I dont know if there is anything you can do about these kind of problems (other than maybe add it to a troubleshooting list?), so I guess this issue can be closed?