OSError: no library called "cairo-2" was found

环境

Windows 11

python 3.8.13 (anaconda->envs)

PyCharm 

 

场景

我使用了GitHub上的第三方组件进行GUI开发,https://github.com/KhamisiKibet/QT-PyQt-PySide-Custom-Widgets

按照README.md中的指示,进行安装后的测试

Installation Testing

Run the following code to see if the installation was successful.

# Run this from your terminal or create a python file, 
# paste this code, then run
from Custom_Widgets.ProgressIndicator import test
test.main()

 

然后得到报错:

        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

 

解决方案

在这个https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer下载:

(此图片源自:https://blog.csdn.net/bz_xyz/article/details/104637487)

 

下载并安装(一路默认选项即可,当然你也可以把安装位置换到你喜欢的任何位置都可),结束后可以发现系统变量 PATH 已经自动加入环境变量:C:\Program Files\GTK3-Runtime Win64\bin,如果没有需要自行加入。

然后重启你的开发环境(PyCharm)或者VS Code,进行测试,如果仍然存在问题,则,

在系统环境变量中,将上文提到的path路径上移到最前面,保证最开始能读取到该路径,重启开发环境,即可解决问题!

 

posted @ 2022-05-18 16:40  禅主  阅读(2516)  评论(0编辑  收藏  举报