I’m currently working on a Tryton upgrade from 4.2 to 5.0 (via intermediate releases 4.4, 4.6 and 4.8). Tryton 5.0 is the first long term support release with support for 5 years. A useful property for an ERP system. In order to test each of the intermediate versions, I decided to quickly spawn a virtualenv and install the Tryton GTK client in there.
$ virtualenv -p python2 venv-tryton-4.4
$ . venv-tryton-4.4/bin/activate
$ pip install tryton~=4.4
$ tryton
Traceback (most recent call last):
File "~/venv-tryton-4.4/bin/tryton", line 48, in <module>
from tryton import client
File "~/venv-tryton-4.4/local/lib/python2.7/site-packages/tryton/client.py", line 17, in <module>
import pygtk
ImportError: No module named pygtk
Installing pygtk
and its dependencies in a virtualenv is not without
its problems. But, there is a rather quick (and hackish) solution to
this problem. This is only suitable for quick tests and experiments. Use
proper Debian packages on production systems.
Python 2.7
$ virtualenv -p python2 venv-tryton-4.4
$ . venv-tryton-4.4/bin/activate
$ pip install tryton~=4.4
$ pip install PyGObject
$ ln -s /usr/lib/python2.7/dist-packages/pygtk.py $VIRTUAL_ENV/lib/python2.7/site-packages
$ ln -s /usr/lib/python2.7/dist-packages/gtk-2.0 $VIRTUAL_ENV/lib/python2.7/site-packages
$ ln -s /usr/lib/python2.7/dist-packages/gobject $VIRTUAL_ENV/lib/python2.7/site-packages
$ ln -s /usr/lib/python2.7/dist-packages/glib $VIRTUAL_ENV/lib/python2.7/site-packages
$ ln -s /usr/lib/python2.7/dist-packages/gi $VIRTUAL_ENV/lib/python2.7/site-packages
$ ln -s /usr/lib/python2.7/dist-packages/pygtkcompat $VIRTUAL_ENV/lib/python2.7/site-packages
$ tryton
Obviously, GTK 2 and the respective Python bindings must be installed.
Python 3.x
$ virtualenv -p python3 venv-tryton-4.8
$ . venv-tryton-4.8/bin/activate
$ pip install tryton~=4.8
$ pip install PyGObject
$ tryton
By the way: Tryton 5.0 and later versions will only support Python 3.x and GTK 3.
Tested on Debian Testing with Python 2.7.15, Python 3.6.6 and Tryton 4.4, 4.6, 4.8 and 5.0.