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

OSError: no library called "cairo-2" was found on Windows #388

Closed
cporrasn opened this issue May 9, 2023 · 7 comments
Closed

OSError: no library called "cairo-2" was found on Windows #388

cporrasn opened this issue May 9, 2023 · 7 comments

Comments

@cporrasn
Copy link

cporrasn commented May 9, 2023

I have this problem:

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': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x7e
cannot load library 'libcairo-2.dll': error 0x7e

I use windows, with a python 3.8.

Installing gtk3 from here: https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases is enough to solve the problem?

@liZe
Copy link
Member

liZe commented May 9, 2023

Installing gtk3 from here: https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases is enough to solve the problem?

Yes, installing with default options and rebooting should be enough.

@sildeag
Copy link

sildeag commented May 16, 2023

I previously posted a solution that worked for me on Windows 11. It is closed as far as I am concerned but apparently a person with greater expertise could apply the same fix to the CairoSVG package and completely fix the issue.

When used in Python3.10 on Windows 11, it is not enough to add the GTK3-Runtime Win64 to the path as the dll still does not load correctly. Adding this solves the issue:
gtkbin = r'C:\Program Files\GTK3-Runtime Win64\bin'
add_dll_dir = getattr(os, 'add_dll_directory', None)
if callable(add_dll_dir):
add_dll_dir(gtkbin)
else:
os.environ['PATH'] = os.pathsep.join((gtkbin, os.environ['PATH']))
import cairosvg

@liZe
Copy link
Member

liZe commented Sep 22, 2024

@farnking Hi!

If you use a recent version of Python and cairocffi, you can set the CAIROCFFI_DLL_DIRECTORIES environment variable to the path where you installed Cairo (this is C:\Program Files\GTK3-Runtime Win64\bin with the GTK3 installer, for example).

@farnking
Copy link

I searched various posts for two days for a solution for Windows. Finally this works. But somehow I restarted the windows like twice before it worked. So initially I thought this another useless post. But it is not.

@farnking
Copy link

I wonder why no one wants to help us windows app developers with a packaged solution?

@liZe
Copy link
Member

liZe commented Sep 22, 2024

I wonder why no one wants to help us windows app developers with a packaged solution?

Open source developers probably prefer to work on and for open source platforms, that’s why, I guess 😄.

If you’re interested in packaging CairoSVG for Windows, maybe you can ask some projects if they would be interested in your help. MSYS2 could be interested in a CairoSVG package, for example.

And if you’d prefer a cairosvg.exe file, you could try to use Pyinstaller: that’s what we do for WeasyPrint for example.

@liZe
Copy link
Member

liZe commented Sep 23, 2024

(Closing, as using CAIROCFFI_DLL_DIRECTORIES works with recent versions of Python and CairoCFFI. Please open another issue if you get the same error.)

@liZe liZe closed this as completed Sep 23, 2024
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

4 participants