question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fontconfig error when trying to run WeasyPrint

See original GitHub issue

Hello,

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:closed
  • Created 2 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xxxxxxmingcommented, Nov 23, 2021

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!

1reaction
RSLak1commented, Apr 25, 2021

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 called fontconfig.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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found