0

I have an old program written in Python2 i need to use, but it's not getting along with Ubuntu Xenial's dependencies.

I had to manually fetch these in order to get it to run:

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

When i run it, i get this:

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.

followed by

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

Using gi.require_version('Gtk', '3.20') results in ValueError: Namespace Gtk not available for version 3.20.

I don't think there's GTK3 for Python2 on Xenial.

The newest python-gtk2 i could find is the one installed, from Bionic. So i went and compiled pybgobject 3.20 after installing a bunch of dependencies:

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

and tried to run it with LD_LIBRARY_PATH=${MY_BASE}/build python2 myprog.py but hit the same issue. I tried variations until LD_LIBRARY_PATH=${MY_BASE}/build/lib/python2.7/site-packages, same result.

Did i compile the wrong package? What am i missing?

These are the packages i have installed at the moment:

$ 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]

Also added these:

libglade2-0_2.6.4-2_amd64.deb
python-glade2_2.24.0-5.1ubuntu2_amd64.deb
vesperto
  • 804
  • 1
  • 6
  • 26
  • You might just want to update the program to Python 3 (however, I don't know how feasible that is, given that I don't know the size of your program). That way, you don't have to install old dependencies for an old version of a language that isn't even maintained anymore. – Sylvester Kruin Feb 15 '22 at 16:43
  • @SylvesterKruin not a rabbit hole i want to get into, really. I shouldn't be using Ubuntu 16.04 to begin with... – vesperto Feb 15 '22 at 16:44
  • It looks to me like, based on old SO [tag:pygtk] questions, that maybe Python 2 uses PyGtk, not Gtk2. Have you tried using that? Again, I strongly suggest you upgrade to Python 3. It may be easier. It certainly will be better in the long run, if you wish to keep using this program (sorry for the slow response, Firefox forced me to update and I had to rewrite the comment). – Sylvester Kruin Feb 15 '22 at 16:57
  • It has `import gi`, so i assume it uses [PyGObject](https://www.gtk.org/docs/language-bindings/python/). I've installed the [latest version](https://pygobject.readthedocs.io/en/latest/getting_started.html#windows-getting-started) through msys and [sys.path.append](https://stackoverflow.com/a/15209116/1831722)ed it to the main script. – vesperto Feb 18 '22 at 09:48
  • (previous comment was about a windows vm, i got the app to start on a xenial vm) – vesperto Feb 18 '22 at 10:14

1 Answers1

0

I've since got it to work on Xenial, but the app doesn't work correctly: the File, Edit, ... menu options don't work, for instance.

From my ever-growing notes, i got it to work by compiling pygobject-3.20.1.tar.xz, with

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  

but i'm not sure that's the path i followed and i was in a temporary directory.

Anyway, now i'm having the same issue in an windows vm.

vesperto
  • 804
  • 1
  • 6
  • 26