Xpra: Ticket #763: use a more friendly error message when the client is started without a display on *nix

Suddenly "xpra attach" fails with the recent 0.14.13 stable build from the repository in CentOS 6.

start/upgrade works.

Maybe some dependency is missing now?

$ xpra --version
xpra v0.14.13
$ xpra attach :1985
xpra main error:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/xpra/scripts/main.py", line 103, in main
    return run_mode(script_file, err, options, args, mode, defaults)
  File "/usr/lib64/python2.6/site-packages/xpra/scripts/main.py", line 761, in run_mode
    return run_client(error_cb, options, args, mode)
  File "/usr/lib64/python2.6/site-packages/xpra/scripts/main.py", line 1109, in run_client
    from xpra.platform.gui import init as gui_init
  File "/usr/lib64/python2.6/site-packages/xpra/platform/gui.py", line 70, in <module>
    "system_bell")
  File "/usr/lib64/python2.6/site-packages/xpra/platform/__init__.py", line 114, in platform_import
    platform_module = __import__(module, {}, {}, imports)
  File "/usr/lib64/python2.6/site-packages/xpra/platform/xposix/gui.py", line 12, in <module>
    from xpra.gtk_common.error import trap, XError
  File "/usr/lib64/python2.6/site-packages/xpra/gtk_common/error.py", line 42, in <module>
    gdk = import_gdk()
  File "/usr/lib64/python2.6/site-packages/xpra/gtk_common/gobject_compat.py", line 83, in import_gdk
    return  _try_import(import_gdk3, import_gdk2)
  File "/usr/lib64/python2.6/site-packages/xpra/gtk_common/gobject_compat.py", line 36, in _try_import
    imported = import_method_gtk3()
  File "/usr/lib64/python2.6/site-packages/xpra/gtk_common/gobject_compat.py", line 80, in import_gdk3
    from gi.repository import Gdk                   #@UnresolvedImport
ImportError: No module named gi.repository


Thu, 11 Dec 2014 21:48:06 GMT - Antoine Martin: owner changed

Looks like it's failing to import pygtk. Nothing has changed in this area for a very long time, so I doubt this is an xpra source or packaging problem.

Try running this from the command line:

python -c "import gtk;import pygtk"

xpra will not work without those. Maybe you have mixed versions, or installed from source previously? If that's the case, try cleaning up everything and re-installing.

Also make sure your python version is python2, and that the /usr/bin/xpra script uses that version and not python3.


Thu, 11 Dec 2014 21:59:40 GMT - Lukas Haase:

Actually, it seems that this error appears when no X server is started. I forgot to start th X server (your proposed command resulted in "RuntimeError?: could not open display").

it's probably a good idea to catch this exception, print a meaningful error message and exit...


Thu, 11 Dec 2014 22:40:09 GMT - Antoine Martin: owner, priority, status, summary changed

Yes, I can get the same error with:

DISPLAY= xpra attach

The problem is that when we fail with pygtk, we try gobject introspection (gi.repository) - this is the error you are seeing.

  1. It's difficult to choose which one to show the user
  2. On many platforms (ie: win32, osx), we may not have a display and yet gtk will load fine..

Thu, 11 Dec 2014 22:58:44 GMT - Antoine Martin:

Fix for trunk in r8240, with this change I get:

$ DISPLAY= xpra attach
xpra initialization error: could not open display

Will backport to v0.14.x so keeping this ticket open.


Thu, 18 Dec 2014 08:45:21 GMT - Antoine Martin: status changed; resolution set

Backport in r8254. Closing.


Sat, 23 Jan 2021 05:05:15 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/763