Kozea / CairoSVG

Convert your vector images
https://courtbouillon.org/cairosvg
GNU Lesser General Public License v3.0
748 stars 150 forks source link

no library called cairo-2, Cairo, libcairo-2, #392

Open tasteitslight opened 1 year ago

tasteitslight commented 1 year ago

MacOS - This is after brew install cairo

Traceback shows:

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': dlopen(libcairo.so.2, 0x0002): tried: 'libcairo.so.2' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcairo.so.2' (no such file), '/usr/lib/libcairo.so.2' (no such file, not in dyld cache), 'libcairo.so.2' (no such file), '/usr/local/lib/libcairo.so.2' (no such file), '/usr/lib/libcairo.so.2' (no such file, not in dyld cache).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo.so.2'
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 0x0002): tried: 'libcairo.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file, not in dyld cache), 'libcairo.2.dylib' (no such file), '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file, not in dyld cache).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo.2.dylib'
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 0x0002): tried: 'libcairo-2.dll' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibcairo-2.dll' (no such file), '/usr/lib/libcairo-2.dll' (no such file, not in dyld cache), 'libcairo-2.dll' (no such file), '/usr/local/lib/libcairo-2.dll' (no such file), '/usr/lib/libcairo-2.dll' (no such file, not in dyld cache).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo-2.dll'
infacto commented 1 year ago

Same here. Example:

pip3 install cairosvg

docs

from cairosvg import svg2pdf
svg2pdf(url='./input/test.svg', write_to='./input_tmp/test.png')

Python 3.11.4 - Windows 10

Any idea?

sildeag commented 1 year ago

The solution was given in #388 and #329. But a more permeant resolution is possible in the source code to anyone more experienced following the instructions also previously given on this site.

jdegenstein commented 7 months ago

One possible solution (for windows especially): use pycairo instead of cairocffi the benefit of this on Windows is that it provides a pyd cairo binary in the wheel. I don't know the broader implications of this change, but it could provide a "pure pip" installation method on windows which seems valuable to me.

maxarvid commented 6 months ago

For OSX users: I had the same issue that I managed to solve by setting the following variable in my .zshrc (should be the same if you are using bash in .bashrc or .bash_profile):

export DYLD_LIBRARY_PATH="/opt/homebrew/opt/cairo/lib:$DYLD_LIBRARY_PATH"

My problem (MBP M1) was that the Python shipped with OSX could not resolve packages installed with Homebrew without this. Hopefully it will not disappear on me.

Don't forget the $ source .zshrc once you've added the variable.