OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 2): image not found
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 2): image not found
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 2): image not found
Error comes when i try to use weasyprint library, I have checked so many solutions but didn't find the clear solution for MacOs(BigSur version 11.6). I'm using python version 3.7. I have tried to use weasyprint with python 3.9 for which it is working perfectly fine.
Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import weasyprint
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/__init__.py", line 440, in <module>
from .css import preprocess_stylesheet # noqa isort:skip
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/css/__init__.py", line 30, in <module>
from . import computed_values, media_queries
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/css/computed_values.py", line 18, in <module>
from .. import text
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/weasyprint/text.py", line 14, in <module>
import cairocffi as cairo
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/cairocffi/__init__.py", line 50, in <module>
('libcairo.so.2', 'libcairo.2.dylib', 'libcairo-2.dll'))
File "/Users/shashank/Desktop/work/env/lib/python3.7/site-packages/cairocffi/__init__.py", line 45, in dlopen
raise OSError(error_message) # pragma: no cover
OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 2): image not found
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 2): image not found
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 2): image not found
for Python version 3.9
(penv) shashank@Shashanks-MacBook-Pro pdf % python3 manage.py shell
Python 3.9.9 (main, Nov 21 2021, 03:16:13)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import weasyprint
>>>
It would be great help if anyone guide me through this problem. Thanks in Advance