最近在学习使用manim制作一些动画,安装manim的时候需要安装依赖pycairo,安装依赖的过程中出现如下的错误:
Collecting pycairo
Using cached http://mirrors.aliyun.com/pypi/packages/19/4f/0d48a017090d4527e921d6892bc550ae869902e67859fc960f8fe63a9094/pycairo-1.26.1.tar.gz (346 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pycairo
Building wheel for pycairo (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pycairo (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-13.0-x86_64-cpython-312
creating build/lib.macosx-13.0-x86_64-cpython-312/cairo
copying cairo/__init__.py -> build/lib.macosx-13.0-x86_64-cpython-312/cairo
copying cairo/__init__.pyi -> build/lib.macosx-13.0-x86_64-cpython-312/cairo
copying cairo/py.typed -> build/lib.macosx-13.0-x86_64-cpython-312/cairo
running build_ext
'pkg-config' not found.
Command ['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pycairo
Failed to build pycairo
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pycairo)
一开始以为是网络问题,重新尝试几次后仍然出现,经过度娘后,通过如下方式解决:
brew install cairo pkg-config
如果是linux的话,可以通过如下方式解决:
sudo apt install libcairo2-dev pkg-config python3-dev #debian
sudo dnf install cairo-devel pkg-config python3-devel #fedora