3

I'm getting this error when trying to start the Django server by using the python manage.py runserver command.

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

I'm using python 3.7, django==2.2.5, and Mac BigSur version 11.0.1.

Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62
Swathi C
  • 31
  • 2
  • Does [this answer](https://stackoverflow.com/a/60926387/9568847) help you? (`pip install cairocffi`) – Niklas Mertsch Dec 25 '20 at 09:59
  • Else please specify what you are trying to do, what code exactly causes the error and how you tried to fix it. Django does not require cairo by itself. – Niklas Mertsch Dec 25 '20 at 10:03
  • Did you manage to solve the problem? I am facing the exact same problem after migrating to Big Sur, also using the exact same versions of everything, all the dependencies where installed and the exact same packages where installed from the requirements.txt file i was working in my previous pc. – Luis Rodriguez Dec 31 '20 at 21:28
  • I'm also finding this trying to use Weasyprint. – Tony Horrocks Jun 11 '21 at 13:20
  • 1
    @TonyHorrocks I am facing the same exact issue while using WeasyPrint on Mac M1. Are you able to find any solution? – Sulove Bista Jul 12 '21 at 13:26
  • Not yet! Using 11.5.2 Bug Sur – Tony Horrocks Aug 22 '21 at 17:44
  • @SuloveBista Same issue using Macbook pro M1. I am trying to import cairosvg . – neic Mar 10 '22 at 07:14
  • I have found a solution for Mac M1 while installing weasyprint, have commented in the answer. have a look, might be of help to you @TonyHorrocks – Sulove Bista Mar 22 '22 at 07:10
  • To solve the problem, I just made a link from the current folder to the homebrew cairo located in /opt/homebrew/lib/libcairo.2.dylib. ln -s /opt/homebrew/lib/libcairo.2.dylib . I ran the command again and it worked perfectly! – Namwanza Ronald Mar 14 '23 at 20:17

2 Answers2

1

To solve the problem, I just made a link from the current folder to the homebrew cairo located in /opt/homebrew/lib/libcairo.2.dylib.

ln -s /opt/homebrew/lib/libcairo.2.dylib .

I ran the command again and it worked perfectly!

Namwanza Ronald
  • 150
  • 1
  • 1
  • 12
-1

For Mac M1, I was facing this issue while trying to install weasyprint and it got solved by downgrading the version of weasyprint to 53.3.

Sulove Bista
  • 118
  • 8