The issue is quite simple. I've installed Python and Cairo with Homebrew since I use a M1 MacBook. When trying to import the package, I get this error:
>>> import cairo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cairo/__init__.py", line 1, in <module>
from ._cairo import * # noqa: F401,F403
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cairo/_cairo.cpython-39-darwin.so, 2): Symbol not found: _cairo_append_path
Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cairo/_cairo.cpython-39-darwin.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cairo/_cairo.cpython-39-darwin.so
Thank you in advance.
Looking at this issue over on their GitHub, and in particular this comment, you could try a couple things:
python3
in the terminal)pycairo
as you have it now and install py3cairo
with homebrewpython3
and the --system-site-package
option i.e. python3 -m venv --system-site-package path/to/env
Check out the comment itself, and let me know if any of this works. There didn't seem to be one clear solution for the issue.