Python problem with upgrade from 19.10 to 20.04
Colin Watson
cjwatson at ubuntu.com
Fri Jul 24 11:49:06 UTC 2020
On Thu, Jul 23, 2020 at 09:55:35PM +0100, Chris Green wrote:
> I have recently upgraded my desktop system from ubuntu 19.10 to ubuntu
> 20.04. I have some Oki printer/scanner driver software that is
> written in Python 2 and, although python 2 is still installed on my
> system it's no longer the default python and the Oki software no
> longer runs.
>
> The error I am getting is:-
>
> chris at esprimo$ ./scantool.py
> Traceback (most recent call last):
> File "./scantool.py", line 52, in <module>
> import gtk
> ImportError: No module named gtk
>
> So what do I need to install on my Ubuntu 20.04 system to provide the
> gtk module?
That used to be python-gtk2, but it's probably unreasonably hard to
install it on Ubuntu 20.04, unless you can find a PPA that you trust
and that provides it.
Have you tried asking your software vendor for an updated program? It
sounds like this program was written for Python 2 (which has been
clearly on the way out for some years, and is officially end-of-life as
of the start of this year), and also for GTK+ 2 (last full release
2011-01-30; last maintenance patch 2018-01-08). Ubuntu provided both
stacks for a very long overlap time, and they should have had time to
come up with something a little more current by now.
> Alternatively (but much harder work) what is the Python 3 equivalent
> of the the Python 2 pygtk and gtk modules.
The old-style PyGTK bindings were never ported to Python 3; the modern
approach is to use the gobject-introspection-based bindings, using
python3-gi and gir1.2-gtk-3.0. (I believe the impetus for moving to
these is that the bindings could be maintained with much less manual
effort; and by "modern" I mean that I have a child learning to program
who's younger than them.)
This GNOME wiki page may help, and if the script is small enough and you
have a bit of familiarity with Python then you may be able to do the
port fairly mechanically:
https://wiki.gnome.org/Projects/PyGObject/IntrospectionPorting#Porting_from_PyGTK_2_to_PyGI_GTK_3
--
Colin Watson (he/him) [cjwatson at ubuntu.com]
More information about the ubuntu-users
mailing list