cannot load library libcairo
Asked Answered
A

3

12

I have problem when trying to run a website in Django:

OSError: no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': /lib/x86_64-linux-gnu/libfontconfig.so.1: undefined symbol: FT_Done_MM_Var
cannot load library 'libcairo.so': /lib/x86_64-linux-gnu/libfontconfig.so.1: undefined symbol: FT_Done_MM_Var
cannot load library 'libcairo.2.dylib': libcairo.2.dylib: cannot open shared object file: No such file or directory
cannot load library 'libcairo-2.dll': libcairo-2.dll: cannot open shared object file: No such file or directory

Althought the package is installed.

I have installed weasyprint

pip3 install weasyprint

python -m pip install WeasyPrint




  sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info

I also tried

sudo apt install libcairo2-dev
sudo apt install libgirepository1.0-dev

I have Lubuntu system. Any ideas how can I fix it? Thanks in advance

Ambroid answered 19/2, 2020 at 20:53 Comment(6)
Did you install everything, that is mentioned in the docs: weasyprint.readthedocs.io/en/stable/install.html#debian-ubuntuRuffo
yes, I did (if the commend they wrote install all of necessary packages)Ambroid
Try uninstalling and installing weasyprint after installing libcairo. Also, undefined symbol: FT_Done_MM_Var error may indicate some conflict with freetype package - is custom freetype-xxx installed?Rearrange
Your fontconfig was build against a newer version of freetype, but somehow ends up being loaded with an older version of freetype, hence the undefined version. Either, there is another libfreetype.so somewhere, or you replaced your /usr/lib/x86_64-linux-gnu/libfreetype.so with an older version and everything is broken.Illuviation
Running nm -DS /usr/lib/x86_64-linux-gnu/*freetype.so | grep FT_Done can tell you if there is a FT_Done_MM_Var function in there. (There are other functions that begin with FT_Done - this is only there to ensure things work correctly, e.g. you should always see FT_Done_Face in the output.)Illuviation
Sorry for answering late- recenlty I had no time to finish my installation. I have reinstalled WeasyPrint. I have no freetype package (at least not listed by pip list). I also see FT_Done_MM_Var function after typing nm -DS /usr/lib/x86_64-linux-gnu/*freetype.so | grep FT_Done. The error is still the sameAmbroid
I
17

For Ubuntu 20 and Debian based distro, try:

sudo apt-get install libpangocairo-1.0-0
Incompliant answered 4/1, 2021 at 8:35 Comment(2)
Worked for me..Thanks..!!!. Can you explain the problem?Partlet
@basharpazhedath, really I don't have obviously a great cause about it, we just install a missed package which is the Pango library (for the layout and rendering of text, font handling for GTK+)Incompliant
A
0

The solution was to remove libfreetype.so.6 file from home/user/anaconda3/envs/myvenv/lib directory (idea taken from https://kb.tecplot.com/2019/09/11/undefined-symbol-ft_done_mm_var/)

Ambroid answered 30/7, 2020 at 14:24 Comment(0)
C
0

For anyone coming here that is getting the error:

/lib/x86_84-linux-gnu/libcairo.so.2: undefined symbol: FT_Done_MM_Var

Run the command:

sudo find / -name *freetype*

As Uli Schlachter mentioned it's due to fonts being built in a newer version and used in an older version. I used alis01's comment to find out that for me:

/usr/lib/jvm/java-8-openjdk/jre/lib/amd64/libfreetype.so.6

was causing the issue. I renamed it to libfreetype.so.6.bak and all has been well since.

Cirro answered 6/10, 2020 at 10:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.