Fix Win 10 OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2 Error – Python Tutorial

By | August 27, 2019

When you are using python cairosvg library to convert svg to png, you may find OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2 / cairo.so.2 error. In this tutorial, we will introduce how to fix this error.

osError - dlopen fail to laod cairo library

Activate python 3 environment

If you have install conda, you should activate python 3 environment. Because cairosvg library can be run python 3.5+.

activate py3

Install cairosvg library

pip install cairosvg

Install cairosvg dependencies

This is the most important way, you should install cairosvg dependencies, then this error can be fixed.

(py3) C:\Users\fly165>conda install -c conda-forge cairo

install cairosvg dependencies

 

Leave a Reply

Your email address will not be published. Required fields are marked *