Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load fontconfig in pyinstaller standalone #1898

Closed
Raizencorp opened this issue Jun 20, 2023 · 10 comments
Closed

Cannot load fontconfig in pyinstaller standalone #1898

Raizencorp opened this issue Jun 20, 2023 · 10 comments

Comments

@Raizencorp
Copy link

Hi,
So whenever i compile my standalone with pyinstaller i get this message:
C:\Users\Cyril_Gainon\PycharmProjects\manufacturing-testing-tool\venv\lib\site-packages\weasyprint\text\fonts.py:62: UserWarning: FontConfig cannot load default config file. Expect ugly output.
warn('FontConfig cannot load default config file. Expect ugly output.')

At first i had only rectangle displayed on my pdf, but i upgrader to the last weasyprint 59.0 and i still have this error when creating my standalone with pyinstaller but now on my application i have this error:

AttributeError: function/symbol 'pango_context_set_round_glyph_positions' not found in library 'C:\Users<name>\AppData\Local\Temp_MEI83642\pango-1.0-0.dll': error 0x7f

Here is all the package i installed so far:
streamlit == 1.22.0
pythonping == 1.1.4
weasyprint==59.0
opencv-python == 4.5.1.48
blur-detector == 0.0.6
streamlit-ext == 0.1.7
deepdiff == 6.3.0
paramiko == 3.1.0
beautifulsoup4 == 4.12.2
lxml == 4.9.2
pandas == 2.0.1
numpy == 1.21.1
requests == 2.28.2
pydub == 0.25.1
scipy == 1.9.1
xlrd == 2.0.1
flirimageextractor == 1.5.1
matplotlib == 3.5.3
loguru == 0.7.0
pytest == 7.3.1
pyinstaller == 5.10.1
pydyf==0.6.0
cffi==1.15.1
html5lib==1.1
fonttools==4.39.4
tinycss2==1.2.1
cssselect2==0.7.0
pyphen==0.14.0
pillow==9.5.0
ffmpeg==1.4

@liZe
Copy link
Member

liZe commented Jun 20, 2023

Hi!

So whenever i compile my standalone with pyinstaller i get this message:

It means that the version of FontConfig you’re using is not configured to find any fonts. I don’t know how you did install FontConfig, but it’s configured correctly with the GTK3 installer proposed by the official documentation.

AttributeError: function/symbol 'pango_context_set_round_glyph_positions' not found in library 'C:\Users\<name>\AppData\Local\Temp\_MEI83642\pango-1.0-0.dll': error 0x7f

It means that your version of Pango is not 1.44+ as asked by the documentation. The pango_context_set_round_glyph_positions function has been added in Pango 1.44. The GTK3 installer provides Pango 1.50.3.

@Raizencorp
Copy link
Author

Raizencorp commented Jun 20, 2023

Thanks you so much for the quick response,. I guess i need to know how to implement the newer version of Pango to pyinstaller but i'm on the wrong repo for this haha

But also i installed the gtk3 on windows, but i think as i said to give it directly to pyinstaller

Edit:
I just cheked GTK3 install folder and the pango file is named 1.0 also it's not a dll file
I also searched on internet it seams that this file is always called pango 1.0. If i'm wrong please correct me

@Raizencorp
Copy link
Author

Raizencorp commented Jun 26, 2023

Hi, i'm back.
So getting the version of pango fixed the display of the error, but it still not working, last thing i have is the:
Fontconfig error: Cannot load default config file: No such file: (null)
C:\Users\<user_name>\PycharmProjects\manufacturing-testing-tool\venv\lib\site-packages\weasyprint\text\fonts.py:62: UserWarning: FontConfig cannot load default config file. Expect ugly output.
warn('FontConfig cannot load default config file. Expect ugly output.')

I've been trying to feed the fonts.conf from linux with modified path, but it feels like it does nothing.

What kind of file is expected, where is he looking for ? (i tried to backtrace in the code but you get back to pango dll)

@liZe
Copy link
Member

liZe commented Jun 26, 2023

Hi!

In the GTK3 installer, Fontconfig’s config files are stored here: https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/tree/master/gtk-nsis-pack/etc/fonts

@Raizencorp
Copy link
Author

Thanks for the info but apparently weasyprint isn't satisfied yet. Or maybe he can't find the fonts.conf ....

@liZe
Copy link
Member

liZe commented Jun 27, 2023

Thanks for the info but apparently weasyprint isn't satisfied yet. Or maybe he can't find the fonts.conf ....

if Fontconfig can’t find the configuration, then there’s probably nothing we can do for you there :/, it’s not directly related to WeasyPrint as it works when it’s not used with pyinstaller. Maybe pyinstaller’s maintainers can help you on this topic?

@Raizencorp
Copy link
Author

Raizencorp commented Jun 27, 2023

Yeah i have an issue opened there too. I'll update it. And if i have the answer post it here too.
Thanks for your help anyway

@liZe
Copy link
Member

liZe commented Jun 27, 2023

Yeah i have an issue opened there too.

Good idea. Could you please write the link of the issue here so that we can follow?

@Raizencorp
Copy link
Author

Hey, sorry i forgot to send the link but here is the fix:

So to make weasyprint work in pynstaller without modifying the file and all i just took an older version of GTK3 and weasyprint. As adviced in this stack.
For me i used the same GTK3 3.24.13-2019-12-19 but it worked with weasyprint 54.3. All errors encountered were gone and no longer needed to add the data of fonts or others.

@liZe
Copy link
Member

liZe commented Jun 29, 2023

Thanks for the link.

That’s strange, because WeasyPrint works correctly on Windows without pyinstaller, with the latest versions of the different libraries. If using older versions works for you, there’s probably no need to find exactly where the problem comes from.

If anyone has this problem and wants to find a solution, don’t hesitate to add a comment, we’ll reopen the issue.

@liZe liZe closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants