Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTK error, failed building on command line #1939

Merged
merged 1 commit into from Aug 2, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Aug 2, 2013

My guess is that the build script is trying to initialise X11 over the terminal, and failing. This only happens in the dev branch.

** (-c:27437): WARNING **: Command line `dbus-launch --autolaunch=613af6694c211a25d65930af0000001a --b
inary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization
failed.\n

Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip-mxUubW-build/setup.py", line 131, in <module>

    result = package.check()

  File "setupext.py", line 1428, in check

    success, msg = p.map(backend_gtk3agg_internal_check, [0])[0]

  File "/usr/lib/python2.7/multiprocessing/pool.py", line 227, in map

    return self.map_async(func, iterable, chunksize).get()

  File "/usr/lib/python2.7/multiprocessing/pool.py", line 528, in get

    raise self._value

RuntimeError: Gtk couldn't be initialized

@pelson
Copy link
Member

pelson commented Apr 24, 2013

Could you provide some more info @janrito? Specifically the relevant details from http://matplotlib.org/faq/troubleshooting_faq.html#getting-help.

Cheers,

@confluence
Copy link

I am experiencing the same problem trying to install matplotlib with pip. I'm running Ubuntu Quantal. Here's the output of uname -a:

Linux gethen 3.5.0-32-generic #53-Ubuntu SMP Wed May 29 20:23:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

I can't provide any other debugging information suggested in the FAQ because matplotlib is not installed.

At first I thought this was happening because I was running the command inside screen, but it also fails in a fresh terminal from which I can launch GUI apps successfully.

The line numbers in my error message are different. Here is the full error output from my terminal:

Downloading/unpacking matplotlib Running setup.py egg_info for package matplotlib ============================================================================ Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
            matplotlib: yes [1.3.0]
                python: yes [2.7.3 (default, Sep 26 2012, 21:51:14)  [GCC
                        4.7.2]]
              platform: yes [linux2]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.6.2]
              dateutil: yes [using dateutil version 1.5]
               tornado: yes [tornado was not found. It is required for the
                        WebAgg backend. pip/easy_install may attempt to
                        install it after matplotlib.]
             pyparsing: yes [using pyparsing version 1.5.6]
                 pycxx: yes [Couldn't import.  Using local copy.]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [version 15.0.9]
                   png: yes [version 1.2.49]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: yes [nose 0.11.1 or later is required to run the
                        matplotlib test suite]

OPTIONAL BACKEND EXTENSIONS
                macosx: no  [Mac OS-X only]
                qt4agg: yes [Qt: 4.8.2, PyQt4: 4.9.3]

** (-c:6339): WARNING **: Could not open X display
Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "/tmp/pip-build/matplotlib/setup.py", line 145, in <module>
    result = package.check()
  File "setupext.py", line 1492, in check
    success, msg = p.map(backend_gtk3agg_internal_check, [0])[0]
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 250, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 554, in get
    raise self._value
RuntimeError: Gtk couldn't be initialized

@janrito
Copy link
Author

janrito commented Aug 2, 2013

Sorry, I forgot about this ticket. The latest 1.3 version suffers of the same issue. It cannot be installed in a headless server.

$ uname -a

Linux cleopatra 3.2.0-40-generic #64-Ubuntu SMP Mon Mar 25 21:22:10 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

No changes to setup.py, and I doubt matplotlibrc is affecting the install but here it is:

font.family        : sans-serif
font.serif         : Computer Modern Roman
font.sans-serif    : Computer Modern Sans serif
font.cursive       : Zapf Chancery
font.monospace     : Computer Modern Typewriter
font.size          : 10.0

text.usetex        : true
text.latex.preamble : \usepackage{sfmath}


# Legend
legend.fontsize    : small

# Figure
figure.dpi         : 150

$ gcc --version

gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ python setup.py build

============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [1.3.0]
                python: yes [2.7.3 (default, Apr 10 2013, 06:20:15)  [GCC
                        4.6.3]]
              platform: yes [linux2]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.8.0.dev-d8370da]
              dateutil: yes [using dateutil version 2.1]
               tornado: yes [using tornado version 3.1]
             pyparsing: yes [pyparsing was not found. It is required for
                        mathtext support. pip/easy_install may attempt to
                        install it after matplotlib.]
                 pycxx: yes [Couldn't import.  Using local copy.]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [version 14.0.8]
                   png: yes [version 1.2.46]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: yes [using nose version 1.3.0]

OPTIONAL BACKEND EXTENSIONS
                macosx: no  [Mac OS-X only]
                qt4agg: yes [Qt: 4.8.1, PyQt4: 4.9.1]

** (setup.py:25565): WARNING **: Command line `dbus-launch --autolaunch=613af6694c211a25d65930af0000001a --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
Traceback (most recent call last):
  File "setup.py", line 145, in <module>
    result = package.check()
  File "/home/agiacometti/tmp/matplotlib-1.3.0/setupext.py", line 1492, in check
    success, msg = p.map(backend_gtk3agg_internal_check, [0])[0]
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 227, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 528, in get
    raise self._value
RuntimeError: Gtk couldn't be initialized

@mdboom
Copy link
Member

mdboom commented Aug 2, 2013

Interesting. I think I see what the problem is, but I can't seem to reproduce it on my Fedora 19 (with X11 forwarding unavailable). I think what's happening is that with your version of pygobject, initalizing Gtk without X11 fails, whereas on mine it doesn't.

Can you please try running the following on your system, but with and without X11, and send me the results?

    try:
        import gi
    except ImportError:
        return (False, "Requires pygobject to be installed.")

    try:
        gi.require_version("Gtk", "3.0")
    except ValueError:
        return (False, "Requires gtk3 development files to be installed.")

    try:
        from gi.repository import Gtk, Gdk, GObject
    except ImportError:
        return (False, "Requires pygobject to be installed.")

    return (True, "version %s.%s.%s" % (
        Gtk.get_major_version(),
        Gtk.get_micro_version(),
        Gtk.get_minor_version()))

@janrito
Copy link
Author

janrito commented Aug 2, 2013

without X11 forwarding:

** (test.py:7016): WARNING **: Command line `dbus-launch --autolaunch=613af6694c211a25d65930af0000001a --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
Traceback (most recent call last):
  File "test.py", line 28, in <module>
    main()
  File "test.py", line 18, in main
    from gi.repository import Gtk, Gdk, GObject
  File "/usr/lib/python2.7/dist-packages/gi/importer.py", line 76, in load_module
    dynamic_module._load()
  File "/usr/lib/python2.7/dist-packages/gi/module.py", line 224, in _load
    overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
  File "/usr/lib/python2.7/dist-packages/gi/overrides/Gtk.py", line 1533, in <module>
    raise RuntimeError("Gtk couldn't be initialized")
RuntimeError: Gtk couldn't be initialized

with X11 forwarding:

** (test.py:6571): WARNING **: Command line `dbus-launch --autolaunch=613af6694c211a25d65930af0000001a --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
Traceback (most recent call last):
  File "test.py", line 28, in <module>
    main()
  File "test.py", line 18, in main
    from gi.repository import Gtk, Gdk, GObject
  File "/usr/lib/python2.7/dist-packages/gi/importer.py", line 76, in load_module
    dynamic_module._load()
  File "/usr/lib/python2.7/dist-packages/gi/module.py", line 224, in _load
    overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
  File "/usr/lib/python2.7/dist-packages/gi/overrides/Gtk.py", line 1533, in <module>
    raise RuntimeError("Gtk couldn't be initialized")
RuntimeError: Gtk couldn't be initialized

@mdboom
Copy link
Member

mdboom commented Aug 2, 2013

Aha! So the X11 forwarding is a red herring, I think.

I think your machine is in a surprising state of having pygobject installed, but not git gobject introspection bindings for Gtk. (Do you have the gir1.2-gtk-3.0 package installed?)

This isn't a hard requirement of matplotlib, and the intention is that the build should continue without it, however, we need to update our script to handle a RuntimeError in addition to a ImportError when this fails in this way. I'll attach a PR to this issue shortly, and I'd appreciate you testing in your environment, if able.

… for gtk, it throws a RuntimeError, not an ImportError, and we need to catch that.
@mdboom
Copy link
Member

mdboom commented Aug 2, 2013

Can you confirm the attached patch fixes the issue?

@janrito
Copy link
Author

janrito commented Aug 2, 2013

Great! Building succeeds. It does give me these warnings:

** (setup.py:21476): WARNING **: Command line `dbus-launch --autolaunch=613af6694c211a25d65930af000000
1a --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initializ
ation failed.\n
               gtk3agg: no  [Requires pygobject to be installed.]

** (setup.py:21493): WARNING **: Command line `dbus-launch --autolaunch=613af6694c211a25d65930af000000
1a --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initializ
ation failed.\n
             gtk3cairo: no  [Requires pygobject to be installed.]

** (setup.py:21462): WARNING **: Command line `dbus-launch --autolaunch=613af6694c211a25d65930af000000
1a --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initializ
ation failed.\n
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
                gtkagg: no  [The C/C++ header for pygtk (pygtk/pygtk.h)
                        could not be found.  You may need to install the
                        development package.]

Also, I do have gir1.2-gtk-3.0 installed:

$ sudo apt-get install gir1.2-gtk-3.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
gir1.2-gtk-3.0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

mdboom added a commit that referenced this pull request Aug 2, 2013
GTK error, failed building on command line
@mdboom mdboom merged commit 1b3106c into matplotlib:v1.3.x Aug 2, 2013
@mdboom mdboom deleted the gtk-test-without-x11 branch August 7, 2014 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants