Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import issue #381

Open
McClowny opened this issue Feb 21, 2023 · 5 comments
Open

import issue #381

McClowny opened this issue Feb 21, 2023 · 5 comments

Comments

@McClowny
Copy link

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```

@liZe
Copy link
Member

liZe commented Feb 21, 2023

Please install the Cairo library using your Linux distribution’s package manager.

@sildeag
Copy link

sildeag commented Feb 21, 2023

I get similar messages on Windows 11 with Python3.10 when I import cairosvg. Nothing I have tried has eliminated the messages.

@liZe
Copy link
Member

liZe commented Feb 21, 2023

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.

@sildeag
Copy link

sildeag commented Feb 21, 2023

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

@liZe
Copy link
Member

liZe commented Feb 21, 2023

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 :/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants