error: subprocess-exited-with-error 及Package cairo was not found in the pkg-config search path.解决

在升级StableDiffusion后遇到pycairo构建轮子失败的错误,原因是缺失cairo包。解决方案包括在Mac上使用Homebrew安装pkg-config和cairo,然后用pip安装pycairo;在Linux系统中,需通过apt-get安装相关依赖并最后安装pycairo。完成这些步骤后,可以成功解决安装问题并重新启动SD。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

今天使用Stable Diffusion时,按照常规升级插件,升级后SD启动遇到了报错问题:

Collecting pycairo>=1.20.0
  Using cached pycairo-1.23.0.tar.gz (344 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: pycairo
  Building wheel for pycairo (pyproject.toml): started
  Building wheel for pycairo (pyproject.toml): finished with status 'error'
Failed to build pycairo

stderr:   error: subprocess-exited-with-error
  
  × Building wheel for pycairo (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-13-arm64-cpython-310
      creating build/lib.macosx-13-arm64-cpython-310/cairo
      copying cairo/__init__.py -> build/lib.macosx-13-arm64-cpython-310/cairo
      copying cairo/__init__.pyi -> build/lib.macosx-13-arm64-cpython-310/cairo
      copying cairo/py.typed -> build/lib.macosx-13-arm64-cpython-310/cairo
      running build_ext
      Package cairo was not found in the pkg-config search path.
      Perhaps you should add the directory containing `cairo.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'cairo' found
      Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycairo
ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects

[notice] A new release of pip is available: 23.0 -> 23.1.2
[notice] To update, run: pip install --upgrade pip


Warning: Failed to install svglib, some preprocessors may not work.

仔细看了一下 是controlnet插件更新后,按装svglib 出现了问题:

Installing sd-webui-controlnet requirement: svglib
Couldn't install sd-webui-controlnet requirement: svglib.
Command: "/Users/glodcrab/AI2IMG/stable-diffusion-webui/venv/bin/python3.10" -m pip install svglib --prefer-binary
Error code: 1

这里的问题主要是pycairo只是对cairo包的Python绑定。但是cairo 包 并不会被pip进行安装。

在这里,我们通过 Homebrew先安装它。brew install cairo。然后再重新启动SD即可。问题解决。

Mac下解决此问题:

brew install pkg-config
brew install cairo
pip install pycairo

Linux下解决此问题:

sudo apt-get update -y
sudo apt-get install -y pkg-config
sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev
sudo pip install pycairo

可以看到问题解决:

Installing requirements

Installing sd-webui-controlnet requirement: svglib

Installing sd-dynamic-prompts requirements.txt

Launching Web UI with arguments: --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate

No module 'xformers'. Proceeding without it.

(base) [root@localhost py3.8]# pip install PyGObject==3.44.0 -i https://pypi.tuna.tsinghua.edu.cn/simple Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting PyGObject==3.44.0 Using cached https://pypi.tuna.tsinghua.edu.cn/packages/07/73/a034fc1bcd6d402d6f72ff618c093f91ac6921f968cc19806b6a1b1b19c8/PyGObject-3.44.0.tar.gz (720 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting pycairo>=1.16.0 (from PyGObject==3.44.0) Using cached pycairo-1.26.1-cp38-cp38-linux_x86_64.whl Building wheels for collected packages: PyGObject Building wheel for PyGObject (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for PyGObject (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [44 lines of output] running bdist_wheel running build running build_py creating build/lib.linux-x86_64-cpython-38/pygtkcompat copying pygtkcompat/__init__.py -> build/lib.linux-x86_64-cpython-38/pygtkcompat copying pygtkcompat/generictreemodel.py -> build/lib.linux-x86_64-cpython-38/pygtkcompat copying pygtkcompat/pygtkcompat.py -> build/lib.linux-x86_64-cpython-38/pygtkcompat creating build/lib.linux-x86_64-cpython-38/gi copying gi/__init__.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/_constants.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/_error.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/_gtktemplate.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/_option.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/_ossighelper.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/_propertyhelper.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/_signalhelper.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/docstring.py -> build/lib.linux-x86_64-cpython-38/gi copying gi/importer.py -> build/lib
最新发布
04-03
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

魔王阿卡纳兹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值