import issue
when i import cariosvg in my code i get this error
File "main.py", line 3, in <module>
import cairosvg
File "/home/runner/SoreDarkgrayBlogware/venv/lib/python3.10/site-packages/cairosvg/__init__.py", line 26, in <module>
from . import surface # noqa isort:skip
File "/home/runner/SoreDarkgrayBlogware/venv/lib/python3.10/site-packages/cairosvg/surface.py", line 9, in <module>
import cairocffi as cairo
File "/home/runner/SoreDarkgrayBlogware/venv/lib/python3.10/site-packages/cairocffi/__init__.py", line 48, in <module>
cairo = dlopen(
File "/home/runner/SoreDarkgrayBlogware/venv/lib/python3.10/site-packages/cairocffi/__init__.py", line 45, in dlopen
raise OSError(error_message) # pragma: no cover
OSError: no library called "cairo-2" was found
no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': libcairo.so.2: cannot open shared object file: No such file or directory
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```
Please install the Cairo library using your Linux distribution’s package manager.
I get similar messages on Windows 11 with Python3.10 when I import cairosvg. Nothing I have tried has eliminated the messages.
Nothing I have tried has eliminated the messages.
On Windows, you can install GTK3 (keeping the default options) and then reboot your computer, it will work.
Thank you for the tips. I have installed GTK3 and rebooted, these are the messages: Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\me> python3.10 Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import cairosvg; Traceback (most recent call last): File "
", line 1, in File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cairosvg_init_.py", line 26, in from . import surface # noqa isort:skip File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cairosvg\surface.py", line 9, in import cairocffi as cairo File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cairocffi_init_.py", line 48, in cairo = dlopen( File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\cairocffi_init_.py", line 45, in dlopen raise OSError(error_message) # pragma: no cover OSError: no library called "cairo-2" was found no library called "cairo" was found cannot load library 'C:\Program Files\GTK3-Runtime Win64\bin\libcairo-2.dll': error 0x7e cannot load library 'libcairo.so.2': error 0x7e cannot load library 'libcairo.2.dylib': error 0x7e cannot load library 'libcairo-2.dll': error 0x7e
Python found the library in 'C:\Program Files\GTK3-Runtime Win64\bin\libcairo-2.dll', but couldn’t use it for some reason. And to be honest, I have no idea why :/.