ERROR: no X environment? No module named gtk

i am receiving this message on two different systems (HPC sgi) and Mac, when i attempt
cylc graph “registeredName” &.

python 2.7.10 and python 2.7.7.

how do i get the cylc graph command to work?

You haven’t installed the software that Cylc’s GUI applications (including cylc graph) depend on.

https://cylc.github.io/doc/built-sphinx/installation.html#third-party-software-packages

Specifically, you need PyGTK (and the GTK libraries) on your system. Try running cylc check-software - it should report missing dependencies.

as suggested cylc check-software revealed missing software.
by using the anaconda package manager, components were installed:

(p27) bash-3.2$ conda list | grep graphviz
graphviz                  2.40.1               hefbbd9a_2  
pygraphviz                1.3                  py27h1de35cc_1  

(p27) bash-3.2$ conda list | grep gtk
pygtk                     2.24.0               py27_1    vgauthier

however, check-software is not satisfied:

  *OPTIONAL SOFTWARE for the GUI & dependency graph visualisation*             
Python:pygraphviz (any).........................................FOUND (1.3)
graphviz (any)..................................................FOUND (2.40.1)
Python:pygtk (2.0+).............................................NOT FOUND (-)

btw.

(p27) bash-3.2$ python --version
Python 2.7.16 :: Anaconda, Inc.

thanking everyone for their time.

If you are not able to do import gtk in your Python environment, then pygtk is not installed or not functional even if anaconda says it is installed. A bit of googling finds some evidence that pygtk is broken in anaconda (although I’ve not tried it myself). Maybe conda is not pulling in the underlying gtk library, or something like that? Good luck!

OK. i was able to build pygtk from source. after installing pygobject.
cylc check-software is still reporting NOT FOUND for pygtk, while i am able to import pygtk.

         *OPTIONAL SOFTWARE for the GUI & dependency graph visualisation*             

Python:pygraphviz (any)…FOUND (1.3)
graphviz (any)…FOUND (2.38.0)
Python:pygtk (2.0+)…NOT FOUND (-)

                           ****************************                               
                              Core requirements: ok                                  
                            Full-functionality: not ok                                
                           ****************************                               

(p27) schaferk@gordon05:~/pygtk-2.24.0> which python
/p/home/schaferk/anaconda2/envs/p27/bin/python
(p27) schaferk@gordon05:~/pygtk-2.24.0> python
Python 2.7.16 |Anaconda, Inc.| (default, Aug 13 2019, 16:58:16)
[GCC 7.3.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import pygtk

(p27) schaferk@gordon05:~/pygtk-2.24.0> conda list | grep pygtk
pygtk 2.24.0 py27_9 jochym

so?

i was able to build pygtk from source. after installing pygobject.

PyGObject is the successor to PyGTK, not the same thing. Cylc-7 uses PyGTK (and we are currently working on new web interfaces to replace the PyGTK GUIs).

You need to be able to to import gtk - not import pygtk - I presume that does not work for you(?), - that’s what Cylc needs, and that’s what cylc check-software does to check the installation.

Try this:

$ python
Python 2.7.5 (default, Jun 20 2019, 20:27:34) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
>>> gtk.pygtk_version
(2, 24, 0)
>>> gtk.gtk_version
(2, 24, 31)

If that doesn’t work, there is something wrong with your installation.

Unfortunately, as the Cylc User Guide says:

PyGTK typically comes with your system Python. It is allegedly quite difficult to install if you need to do so for another Python version.

(This another reason, albeit a minor one compared to Python 2 end-of-life, that we are working to replace Cylc’s desktop GUIs).

If you are able to start working with Cylc (assuming you haven’t already) on a modern-ish Linux server or VM, the system Python 2 installation should have PyGTK installed out of the box.

<on a modern-ish Linux server or VM, the system Python 2 installation should have PyGTK installed out of the box.

brand new sgi

$ python

Python 2.7.5 (default, Mar 26 2019, 22:13:06)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2

Type “help”, “copyright”, “credits” or “license” for more information.

import pygtk
imports, no issue

you state earlier ‘Cylc-7 uses PyGTK’
<You need to be able to to import gtk - not import pygtk

cylc-check-software loads ‘gtk’ rather than pygtk. the reference to ‘pygtk’ is misleading.

AND

import gtk

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named gtk

i/ll have a chat with the system folks about ‘gtk’, since (apparently),
‘there is something wrong with the installation.’

going forward…

Hi again!

What Linux distribution and version are you running? It would be interesting to know if it is supposed to come with pygtk for Python 2.7.5, or not.

the reference to ‘pygtk’ is misleading.

Sorry if that’s misleading, but I think we can push the blame for that onto the pygtk writers. As I understand it (although I’ve not had to install pygtk myself) the “pygtk” package actually provides “gtk”. Here’s the evidence:

$ python
Python 2.7.5 (default, Apr  9 2019, 14:30:50) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import gtk

>>> help(gtk)
Help on package gtk:

NAME
    gtk

FILE
    /usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py

DESCRIPTION
    # -*- Mode: Python; py-indent-offset: 4 -*-
    # pygtk - Python bindings for the GTK toolkit.
    ^^^^^^^^^
...

So, it’s not clear to me why you can import “pygtk” but not “gtk”. Once you’ve solved this we can consider a change to the installation Cylc documentation for next release.

Hilary

version:
uname -a

Linux gaffney10 3.10.0-957.12.2.el7.x86_64 #1 SMP Fri Apr 19 21:09:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

release:
NAME=“Red Hat Enterprise Linux Server”
VERSION=“7.6 (Maipo)”
ID=“rhel”
ID_LIKE=“fedora”
VARIANT=“Server”
VARIANT_ID=“server”
VERSION_ID=“7.6”
PRETTY_NAME=“Red Hat Enterprise Linux Server 7.6 (Maipo)”
ANSI_COLOR=“0;31”
CPE_NAME=“cpe:/o:redhat:enterprise_linux:7.6:GA:server”
HOME_URL=“https://www.redhat.com/
BUG_REPORT_URL=“https://bugzilla.redhat.com/
REDHAT_BUGZILLA_PRODUCT=“Red Hat Enterprise Linux 7”
REDHAT_BUGZILLA_PRODUCT_VERSION=7.6
REDHAT_SUPPORT_PRODUCT=“Red Hat Enterprise Linux”
REDHAT_SUPPORT_PRODUCT_VERSION=“7.6”

I don’t know that anyone has installed Cylc7 in a Conda environment so this is slightly new territory for us. As Hillary says installation will become much, much easier with Cylc8.

What Linux distribution and version are you running? It would be interesting to know if it is supposed to come with pygtk for Python 2.7.5, or not.

Because we are trying to install Cylc in an anaconda environment I don’t think we can make use of the system pygtk.

(p27) bash-3.2$ conda list | grep gtk
pygtk                     2.24.0               py27_1    vgauthier

There are a few different pygtk conda packages, from the output above you have installed vgauthier/pygtk. It may be worth uninstalling this and trying a different pygtk package to see if that works on your system

I found a page where someone had tried out the different pygtk packages, vgauthier/pygtk did not work on their system.

Also are you on OSX?

Actually, i have tried to get the gui working (read: work out the ‘pygtk’-‘gtk’ thing) with and without anaconda on both OSX machine and sgi machine.
no success.

looks like windoze only.

i/d be happy to move to cylc-8.
in fact i checked out the master for cylc-8, and discovered that documentation (README.md, INSTALL.md) does no seem to be accurate.

if someone could provide a short, to the point, howto for cylc8 i would be grateful.

Cylc 8 is not ready yet and won’t be for some time. However, Cylc 7 is known to work fine on RHEL 7.6. I would stick with the system supplied version of Python rather than trying to use anaconda. In order for the GUIs to work you need to make sure that that the “pygtk2” package is installed (via yum).

Hi @schaferk,

i checked out the master for cylc-8, and discovered that documentation (README.md, INSTALL.md) does no seem to be accurate.

Can you tell us what’s not accurate? The only potentially confusing thing that I can see is that the INSTALL.md file on the master branch still shows cylc-7 installation instructions - but that is about installing from official release tarballs anyway, not using a git clone. Otherwise, the top of the cylc/cylc-flow README on the master branch seems pretty clear to me:

Python 2 or Python 3?
Currently in the source code repository:

  • master branch: Python 3, ZeroMQ network layer, no GUI - Cylc-8 Work In Progress
  • 7.8.x branch: Python 2, Cherrypy network layer, PyGTK GUI - Cylc-7 Maintenance

The first official Cylc-8 release (with a new web UI) is not expected until late 2019. Until then we recommend the latest cylc-7.8 release for production use.

So as @dpmatthews says, Cylc-8 will not be ready for some time yet - unless you are, or want to be, a Cylc developer.

Hilary

I’ve done some quick investigation on my Centos 7.6 system - which I’m led to believe is just RHEL 7.6 without branding and commercial support. Results:

The Cylc GUIs run out of the box with the system-installed Python 2.7.5.

PyGTK (Python bindings for the GTK+ GUI toolkit) is provided by the “pygtk2” yum package (as @dpmatthews noted).

After sudo yum remove pygtk2 I cannot import “gtk” or “pygtk”, and then sudo yum install pygtk2 restores both. Interestingly, however, the “pygtk2” yum package pulls in the “pygobject2” yum package as a dependency, but “pygobject2” can be installed and removed separately from the system. Doing this shows that:

  • the “gtk” Python package - which is what’s needed to use PyGTK - is provided by the “pygtk2” yum package

  • the “pygtk” Python module is NOT supplied by the “pygtk2” yum package! It is just some kind of small version-checking wrapper supplied by the “pygobject2” yum package.

If that’s confusing, it’s down to the vagaries of RedHat yum packaging. I will add to our installation documentation in light of this, for RHEL and Centos users, but note that generally we’ve tried to give generic advice (PyGTK is required) and recommend what’s known to work out of the box (system Python 2.7 with PyGTK) because we can’t really test all distros and packaging systems.

(And finally, soon you will be able to trivially install Cylc with pip or conda - when Cylc 8 is released. We were unable to do that with Cylc 7, largely because of PyGTK).

Hilary

I’m not very expert with conda yet, but it seems to me that none of the (very few) pygtk conda packages available for 64-bit Linux are functional. https://anaconda.org/search?q=access%3Apublic+platform%3Alinux-64+type%3Aconda+pygtk

I suspect the package creators were relying on (non-Python) system libraries that they did not include in their packages, and which have changed since in more modern distros.

@hilary.j.oliver That’s correct. I managed to get a conda gtk working several years ago, but haven’t been able to replicate it since. On RHEL7 systems now I rely on a virtual environment that has the system site packages in it.

1 Like