No library called "cairo-2"

Hi Support, @regbers
Has anyone anyone else come across this issue, or similar?
I am trying to run an existing app (made using docker) through the venv. Install produces no issues, only when i try to start the app do i get the following errors:

2022-03-31 14:23:41.386 INFO    :     | |   | |  | | |  _  /
2022-03-31 14:23:41.386 INFO    :     | |   | |__| | | | \ \
2022-03-31 14:23:41.386 INFO    :     |_|    \____/  |_|  \_\
2022-03-31 14:23:41.386 INFO    : VIKTOR connector v5.12.1
2022-03-31 14:23:41.387 INFO    : VIKTOR SDK v12.7.0
2022-03-31 14:23:41.387 INFO    : Loading SDK...
Traceback (most recent call last):
  File "viktor_connector\connector.pyx", line 692, in connector.ManifestHandler.run
  File "C:\Users\xxxx\app\__init__.py", line 1, in <module>
    from .gef.controller import Controller as GEFFileController
  File "C:\Users\xxxx\app\gef\controller.py", line 4, in <module>
    from cairosvg import svg2pdf
  File "C:\Users\xxxx\venv\lib\site-packages\cairosvg\__init__.py", line 26, in <module>
    from . import surface  # noqa isort:skip
  File "C:\Users\xxxx\venv\lib\site-packages\cairosvg\surface.py", line 9, in <module>
    import cairocffi as cairo
  File "C:\Users\xxxx\venv\lib\site-packages\cairocffi\__init__.py", line 50, in <module>
    ('libcairo.so.2', 'libcairo.2.dylib', 'libcairo-2.dll'))
  File "C:\Users\xxxx\venv\lib\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': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x7e
cannot load library 'libcairo-2.dll': error 0x7e

2022-03-31 14:23:42.063 ERROR   : 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

Thanks for any help

Thanks for posting Natalie.

At the moment I’m not sure what causes this, but I can confirm that using the import from cairosvg import svg2pdf with the requirement cairosvg==2.5.1 leads to the same issue on a random application installed with the venv isolation mode of the cli.
The exact same import + requirement is working in WSL2 when using the docker isolation mode of the cli. Nevertheless, this is something we should investigate and we will come back to you when we know more.

1 Like

Hi Nathalie,

It seems that cairoSVG requires some additional depencies to work on Windows. From the documentation:

CairoSVG and its dependencies may require additional tools during the installation: a compiler, Python headers, Cairo, and FFI headers. These tools have different names depending on the OS you are using, but:

  • on Windows, you’ll have to install Visual C++ compiler for Python and Cairo;

Did you know that we also have a svg to pdf conversion service in the SDK? You can find it in the docs here: Services - Converting to PDF | VIKTOR Documentation.