GLib.Error:必需的GTK+版本3.20,当前版本为3.18(7)

GLib.Error: Required gtk+ version 3.20, current version is 3.18 (7)(GLib.Error:必需的GTK+版本3.20,当前版本为3.18(7))

本文介绍了GLib.Error:必需的GTK+版本3.20,当前版本为3.18(7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Python2编写的旧程序需要使用,但它与Ubuntu Xenial的依赖项相处不好。

我必须手动获取这些才能使其运行:

libwebp6_0.6.1-2ubuntu0.18.04.1_amd64.deb
libwebpdemux2_0.6.1-2ubuntu0.18.04.1_amd64.deb
libwebpmux3_0.6.1-2ubuntu0.18.04.1_amd64.deb
python-pil_5.1.0-1ubuntu0.7_amd64.deb
python-gtk2_2.24.0-5.1ubuntu2_amd64.deb

当我运行它时,我得到这样的结果:

myprog.py:12: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.

后跟

GLib.Error: ... Required gtk+ version 3.20, current version is 3.18 (7)

使用gi.require_version('Gtk', '3.20')会导致ValueError: Namespace Gtk not available for version 3.20

我认为Xenial上没有针对Python2的GTK3。

我能找到的最新python-gtk2是从Bionic安装的。所以我在安装了一堆依赖项后,编译了pybgobject3.20:

export GI_LIBS="-L/usr/lib/x86_64-linux-gnu -lglib-2.0"
export GI_CFLAGS="-I/usr/include/glib-2.0 -I/usr/include/glib-2.0/include"
export PYCAIRO_CFLAGS="-I/usr/include/pycairo"
export CPPFLAGS="-I/usr/include/gobject-introspection-1.0"
./configure --prefix=${MY_BASE}/build --enable-static --enable-shared --with-python=python2

并尝试使用LD_LIBRARY_PATH=${MY_BASE}/build python2 myprog.py运行它,但遇到了相同的问题。我尝试了各种变化,直到LD_LIBRARY_PATH=${MY_BASE}/build/lib/python2.7/site-packages,结果相同。

我是不是编译错了包?我错过了什么?

这些是我目前安装的包:

$ apt list --installed|grep python|grep -v python3

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

dh-python/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2.20151103ubuntu1.2 all [installed]
libpython-dev/xenial-updates,now 2.7.12-1~16.04 amd64 [installed,automatic]
libpython-stdlib/xenial-updates,now 2.7.12-1~16.04 amd64 [installed]
libpython2.7/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.13 amd64 [installed]
libpython2.7-dev/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.13 amd64 [installed]
libpython2.7-minimal/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.13 amd64 [installed]
libpython2.7-stdlib/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.13 amd64 [installed]
python/xenial-updates,now 2.7.12-1~16.04 amd64 [installed]
python-apt-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1.1.0~beta1ubuntu0.16.04.11 all [installed]
python-cairo/xenial,now 1.8.8-2 amd64 [installed,automatic]
python-cairo-dev/xenial,xenial,now 1.8.8-2 all [installed]
python-cheetah/xenial,now 2.4.4-3.fakesyncbuild1 amd64 [installed,automatic]
python-configparser/xenial,xenial,now 3.3.0r2-2 all [installed]
python-dev/xenial-updates,now 2.7.12-1~16.04 amd64 [installed]
python-dialog/xenial,now 3.3.0-2 amd64 [installed]
python-gi/xenial,now 3.20.0-0ubuntu1 amd64 [installed,automatic]
python-gi-cairo/xenial,now 3.20.0-0ubuntu1 amd64 [installed]
python-gi-dev/xenial,now 3.20.0-0ubuntu1 amd64 [installed]
python-gobject/xenial,xenial,now 3.20.0-0ubuntu1 all [installed]
python-gobject-2/xenial,now 2.28.6-12ubuntu1 amd64 [installed,automatic]
python-gobject-2-dev/xenial,xenial,now 2.28.6-12ubuntu1 all [installed]
python-gobject-dev/xenial,xenial,now 3.20.0-0ubuntu1 all [installed]
python-gtk2/now 2.24.0-5.1ubuntu2 amd64 [installed,local]
python-libvirt/xenial-updates,now 1.3.1-1ubuntu1.1 amd64 [installed,automatic]
python-mako/xenial,xenial,now 1.0.3+ds1-1ubuntu1 all [installed,automatic]
python-markupsafe/xenial,now 0.23-2build2 amd64 [installed,automatic]
python-minimal/xenial-updates,now 2.7.12-1~16.04 amd64 [installed]
python-mysqldb/xenial,now 1.3.7-1build2 amd64 [installed]
python-pil/now 5.1.0-1ubuntu0.7 amd64 [installed,local]
python-pip/xenial-updates,xenial-updates,xenial-security,xenial-security,now 8.1.1-2ubuntu0.6 all [installed]
python-pip-whl/xenial-updates,xenial-updates,xenial-security,xenial-security,now 8.1.1-2ubuntu0.6 all [installed,automatic]
python-pkg-resources/xenial,xenial,now 20.7.0-1 all [installed,automatic]
python-pygments/xenial,xenial,now 2.1+dfsg-1 all [installed,automatic]
python-sqlalchemy/xenial,xenial,now 1.0.11+ds1-1ubuntu2 all [installed]
python-talloc/xenial,now 2.1.5-2 amd64 [installed]
python-vm-builder/xenial,xenial,now 0.12.4+bzr494-0ubuntu1 all [installed,automatic]
python-yaml/xenial,now 3.11-3build1 amd64 [installed,automatic]
python2.7/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.13 amd64 [installed]
python2.7-dev/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.13 amd64 [installed,automatic]
python2.7-minimal/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.13 amd64 [installed]

还添加了这些:

libglade2-0_2.6.4-2_amd64.deb
python-glade2_2.24.0-5.1ubuntu2_amd64.deb

推荐答案

我后来让它在Xenial上运行,但这个应用程序不能正常工作:文件、编辑、...例如,菜单选项不起作用。

根据我不断增长的笔记,我通过编译pygobject-3.20.1.tar.xz使其工作,

export GI_LIBS="-L/usr/lib/x86_64-linux-gnu -lglib-2.0"
export GI_CFLAGS="-I/usr/include/glib-2.0 -I/usr/include/glib-2.0/include"
export PYCAIRO_CFLAGS="-I/usr/include/pycairo"
export CPPFLAGS="-I/usr/include/gobject-introspection-1.0"
./configure --prefix=${PWD}/build/linux/x86_64 --enable-static --enable-shared --with-python=python2  

但我不确定这是我所遵循的路径,并且我在一个临时目录中。

不管怎样,现在我在Windows VM中遇到了同样的问题。

这篇关于GLib.Error:必需的GTK+版本3.20,当前版本为3.18(7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:GLib.Error:必需的GTK+版本3.20,当前版本为3.18(7)

基础教程推荐