mkdocs-material: Cairocffi can't find cairo library

Context

I’m running mkdocs locally on my M1 mac and using poetry to manage my virtual environment. The same issue occurs if you use pip.

Bug description

To use the social plugin, mkdocs requires installing pillow and cairosvg. Additionally, Cairo Graphics and its dependencies must be installed as stated in the docs. I’m using an M1 mac so I used the following command:

brew install cairo freetype libffi libjpeg libpng zlib

These libraries installed without issue. However, upon running mkdocs serve I receive the following error:

OSError: no library called "cairo-2" was found
no library called "cairo" was found
no library called "libcairo-2" was found

It appears to be looking for these libraries inside of the python installation instead of inside the homebrew folder. My current workaround is to use the following environment variable as mentioned in this issue:

export DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib

Related links

Reproduction

example.zip

Steps to reproduce

  1. Create a virtual environment
  2. Run pip install -r requirements.lock.txt
  3. Run mkdocs serve or mkdocs build

Browser

Other

Before submitting

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@bigmike36c and @bilal-fazlani - After installing cairo with Homebrew, I had to manually copy the library to a location in my path:

cp /opt/homebrew/Cellar/cairo/1.16.0_5/lib/libcairo.2.dylib /usr/local/lib

No, unfortunately I was never able to resolve this issue on my Mac.

@bigmike36c did you ever find the cause of this? I am setting a new M1 Mac and running into same issue.