报错问题:
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. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo.so.2'
cannot load library 'libcairo.2.dylib': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo.2.dylib'
cannot load library 'libcairo-2.dll': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libcairo-2.dll'
解决方案:
在windows上
在这个https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer下载:
下载并安装(一路默认选项即可,当然你也可以把安装位置换到你喜欢的任何位置都可),结束后可以发现系统变量 PATH 已经自动加入环境变量:C:\Program Files\GTK3-Runtime Win64\bin,如果没有需要自行加入。
然后重启你的开发环境(PyCharm)或者VS Code,进行测试,如果仍然存在问题,则,
在系统环境变量中,将上文提到的path路径上移到最前面,保证最开始能读取到该路径,重启开发环境,即可解决问题
在 Ubuntu 上:
sudo apt-get install libcairo2-dev
在 CentOS 上:
sudo yum install cairo-devel
在 macOS 上:
brew install cairo
参考:
https://www.cnblogs.com/zhaoyunt/p/16285254.html windows系统
https://blog.csdn.net/Sayulin/article/details/136034023