python - PyGIWarning : Gtk and Rsvg were imported without specifying a version first. 使用 gi.require_version

标签 python linux centos gtk tryton

$ python -c '从 gi.repository 导入 Gtk' -c:1: PyGIWarning: 导入 Gtk 时未先指定版本。在导入之前使用 gi.require_version('Gtk', '3.0') 以确保加载正确的版本。 我该怎么办?

最佳答案

您收到警告是因为您在导入 gtk 时未指定版本。这是因为 gtk 有多个版本,所以你应该声明要使用哪个版本。

为此,您可以打开 python 终端(在命令行中键入 python)并执行以下代码:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

关于python - PyGIWarning : Gtk and Rsvg were imported without specifying a version first. 使用 gi.require_version,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63631072/

相关文章:

python - 使用 Python 3 打印时出现语法错误

c++ - 如何设置 eclipse 以使用 arm 的代码源工具链

python - 从 Python 插入 MySQL - 错误

PHP-FPM (7.4.2) 没有正常停止?

linux - AWS EC2 Linux 上的 Web2Py

linux - %pre 部分在 kickstart 安装中不起作用

linux - 在centos中安装sqlite3 dev和其他包

node.js - 运行 docker image 不起作用

python - 在使用我的 egg 部署一些支持二进制文件时,如何让 setuptools 设置可执行位?

python - 使用 pyFMI 获取/设置 FMU 字符串