j解决Ubuntu无法安装pycairo和PyGObject

环境:虚拟机Ubuntu20.04,vscode无法安装pycairo和PyGObject

虚拟机Ubuntu20.04,vscode中运行Anaconda搭建的vens 的Python3.8.10
首先在vscode中点击ctrl+shift+p,选择Python3.8.10的环境,自动激活Python

最近在搞无人机精准降落,网上下载的一段代码,总是报错,搞了三四天终于把环境搭好了
其中一段代码(如下)总是报错 ,原因就是没有wheel,然后pycairo和PyGObject安装不上去

import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst

报错先是:
ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
然后接着:
ERROR: Could not build wheels for PyGObject which use PEP 517 and cannot be installed directly

然后参考

  1. ERROR: Could not build wheels for PyGObject which use PEP 517 and cannot be installed directly #45
  2. ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects

安装pycairo

新建Ubuntu终端,输入:

sudo apt-get install sox ffmpeg libcairo2 libcairo2-dev
sudo apt-get install texlive-full

完成以后,基本可以安装pycairo==1.21.0
在vscode的Python终端输入:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycairo==1.21.0

如果不行的话,先输入:

pip3 install manimlib  # or pip install manimlib
pip3 install manimce  # or pip install manimce

然后再次输入

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycairo==1.21.0

安装PyGObject

新建Ubuntu终端输入:

sudo apt install libgirepository1.0-dev

然后在vscode输入

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple PyGObject==3.42.2

如下图:
j解决Ubuntu无法安装pycairo和PyGObject_第1张图片
j解决Ubuntu无法安装pycairo和PyGObject_第2张图片

笔者采用这种办法解决长久折磨我的问题,然后import gi 和Gst都不报错了,如果还是不成功,可以点进我参考的GitHub网址:https://github.com/gfduszynski/cm-rgb/issues/45
找寻其他人成功的方法

你可能感兴趣的:(unbuntu,ubuntu,linux,pycario,PyGObject)