环境:虚拟机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
然后参考
- ERROR: Could not build wheels for PyGObject which use PEP 517 and cannot be installed directly #45
- 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
如下图:
文章来源:https://www.toymoban.com/news/detail-712542.html
笔者采用这种办法解决长久折磨我的问题,然后import gi 和Gst都不报错了,如果还是不成功,可以点进我参考的GitHub网址:https://github.com/gfduszynski/cm-rgb/issues/45
找寻其他人成功的方法文章来源地址https://www.toymoban.com/news/detail-712542.html
到了这里,关于解决Ubuntu无法安装pycairo和PyGObject的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!