无法在 Raspberry Pi 3 中使用 Python3.6 安装 PyGObject

Failed to install PyGObject with Python3.6 in Raspberry Pi 3

我在 Raspberry Pi3 中手动安装了 Python3.6。我正在尝试安装 PyGObject,但失败并出现错误:


ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-f4i084p_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools wheel pycairo
       cwd: None
  Complete output (36 lines):
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
  Collecting setuptools
    Downloading setuptools-50.3.2-py3-none-any.whl (785 kB)
  Collecting wheel
    Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB)
  Collecting pycairo
    Downloading pycairo-1.20.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'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'done'
  Building wheels for collected packages: pycairo
    Building wheel for pycairo (PEP 517): started
    Building wheel for pycairo (PEP 517): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpazwu2ueb
         cwd: /tmp/pip-install-k30bx276/pycairo
    Complete output (12 lines):
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-3.6
    creating build/lib.linux-armv7l-3.6/cairo
    copying cairo/__init__.py -> build/lib.linux-armv7l-3.6/cairo
    copying cairo/__init__.pyi -> build/lib.linux-armv7l-3.6/cairo
    copying cairo/py.typed -> build/lib.linux-armv7l-3.6/cairo
    running build_ext
    Requested 'cairo >= 1.15.10' but version of cairo is 1.14.8
    Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
    ----------------------------------------
    ERROR: Failed building wheel for pycairo
  Failed to build pycairo
  ERROR: Could not build wheels for pycairo which use PEP 517 and cannot be installed directly
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3.6 /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-f4i084p_/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools wheel pycairo Check the logs for full command output.

据我了解,构建 PyCairo-1.20.0 时发生故障,需要 cairo >= 1.15.10' 但 cairo 的版本是 1.14.8。

可能的解决方案:

pycairo-1.20.0 是最近发布的版本(2020 年 10 月 5 日)。 如果构建使用 pycairo-1.19.1,我相信安装会成功,因为它需要 cairo >= 1.13.1.

所以,我的问题是:

  1. 忽略我的“可能的解决方案”,有什么方法可以使用 pip3 安装 PyGObject for python3.6 in Raspberry Pi 3?
  2. 关于我的“可能的解决方案”,如何安装使用 PyCairo-1.19.1 的 PyGObject?

我执行的命令是:

sudo PYGOBJECT_WITHOUT_PYCAIRO=1 pip3 install --no-build-isolation --no-use-pep517 pygobject

在不安装 PyCairo 的情况下安装 PyGObject。

https://github.com/pygobject/pycairo/issues/219