konstantint / matplotlib-venn

Area-weighted venn-diagrams for Python/matplotlib
MIT License
508 stars 68 forks source link

gdk_cursor_new_for_display errors in test phase #21

Closed TheChymera closed 9 years ago

TheChymera commented 9 years ago

Hi, I am trying to run the package test suite, and for some reason it fails. Does it have anything to do with my cursor? o.0

============================================= test session starts ==============================================
platform linux2 -- Python 2.7.10, pytest-2.8.1, py-1.4.30, pluggy-0.3.1
rootdir: /var/tmp/portage/dev-python/matplotlib-venn-9999/work/matplotlib-venn-9999-python2_7/test/lib, inifile: 
collected 1 items / 4 errors

tests/issues_test.py F

==================================================== ERRORS ====================================================
__________________________________ ERROR collecting tests/functional_test.py ___________________________________
tests/functional_test.py:13: in <module>
    from tests.utils import exec_ipynb
tests/utils.py:13: in <module>
    from matplotlib.pyplot import scatter
/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py:109: in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py:32: in pylab_setup
    globals(),locals(),[backend_name],0)
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3agg.py:11: in <module>
    from . import backend_gtk3
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3.py:55: in <module>
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
E   TypeError: constructor returned NULL
----------------------------------------------- Captured stderr ------------------------------------------------
No protocol specified
No protocol specified

(py.test:22001): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
____________________________________ ERROR collecting tests/region_test.py _____________________________________
tests/region_test.py:15: in <module>
    from tests.utils import exec_ipynb
tests/utils.py:13: in <module>
    from matplotlib.pyplot import scatter
/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py:109: in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py:32: in pylab_setup
    globals(),locals(),[backend_name],0)
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3agg.py:11: in <module>
    from . import backend_gtk3
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3.py:55: in <module>
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
E   TypeError: constructor returned NULL
----------------------------------------------- Captured stderr ------------------------------------------------

(py.test:22001): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
_____________________________________ ERROR collecting tests/venn3_test.py _____________________________________
tests/venn3_test.py:11: in <module>
    from matplotlib_venn._venn3 import *
/var/tmp/portage/dev-python/matplotlib-venn-9999/work/matplotlib-venn-9999-python2_7/test/lib/matplotlib_venn-0.11-py2.7.egg/matplotlib_venn/__init__.py:55: in <module>
    ???
/var/tmp/portage/dev-python/matplotlib-venn-9999/work/matplotlib-venn-9999-python2_7/test/lib/matplotlib_venn-0.11-py2.7.egg/matplotlib_venn/_venn2.py:21: in <module>
    ???
/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py:109: in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py:32: in pylab_setup
    globals(),locals(),[backend_name],0)
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3agg.py:11: in <module>
    from . import backend_gtk3
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3.py:55: in <module>
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
E   TypeError: constructor returned NULL
----------------------------------------------- Captured stderr ------------------------------------------------
/usr/lib64/python2.7/site-packages/matplotlib/__init__.py:1318: UserWarning:  This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)

(py.test:22001): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
__________________________________ ERROR collecting tests/venn_ax_kw_test.py ___________________________________
tests/venn_ax_kw_test.py:11: in <module>
    from matplotlib_venn._venn2 import *
/var/tmp/portage/dev-python/matplotlib-venn-9999/work/matplotlib-venn-9999-python2_7/test/lib/matplotlib_venn-0.11-py2.7.egg/matplotlib_venn/__init__.py:55: in <module>
    ???
/var/tmp/portage/dev-python/matplotlib-venn-9999/work/matplotlib-venn-9999-python2_7/test/lib/matplotlib_venn-0.11-py2.7.egg/matplotlib_venn/_venn2.py:21: in <module>
    ???
/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py:109: in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py:32: in pylab_setup
    globals(),locals(),[backend_name],0)
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3agg.py:11: in <module>
    from . import backend_gtk3
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3.py:55: in <module>
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
E   TypeError: constructor returned NULL
----------------------------------------------- Captured stderr ------------------------------------------------

(py.test:22001): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
=================================================== FAILURES ===================================================
________________________________________________ test_issue_17 _________________________________________________

    def test_issue_17():
>       import matplotlib_venn as mv

tests/issues_test.py:12: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/var/tmp/portage/dev-python/matplotlib-venn-9999/work/matplotlib-venn-9999-python2_7/test/lib/matplotlib_venn-0.11-py2.7.egg/matplotlib_venn/__init__.py:55: in <module>
    ???
/var/tmp/portage/dev-python/matplotlib-venn-9999/work/matplotlib-venn-9999-python2_7/test/lib/matplotlib_venn-0.11-py2.7.egg/matplotlib_venn/_venn2.py:21: in <module>
    ???
/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py:109: in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py:32: in pylab_setup
    globals(),locals(),[backend_name],0)
/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3agg.py:11: in <module>
    from . import backend_gtk3
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    from __future__ import (absolute_import, division, print_function,
                            unicode_literals)

    import six

    import os, sys
    def fn_name(): return sys._getframe(1).f_code.co_name

    try:
        import gi
    except ImportError:
        raise ImportError("Gtk3 backend requires pygobject to be installed.")

    try:
        gi.require_version("Gtk", "3.0")
    except AttributeError:
        raise ImportError(
            "pygobject version too old -- it must have require_version")
    except ValueError:
        raise ImportError(
            "Gtk3 backend requires the GObject introspection bindings for Gtk 3 "
            "to be installed.")

    try:
        from gi.repository import Gtk, Gdk, GObject, GLib
    except ImportError:
        raise ImportError("Gtk3 backend requires pygobject to be installed.")

    import matplotlib
    from matplotlib._pylab_helpers import Gcf
    from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
         FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase
    from matplotlib.backend_bases import ShowBase

    from matplotlib.cbook import is_string_like, is_writable_file_like
    from matplotlib.colors import colorConverter
    from matplotlib.figure import Figure
    from matplotlib.widgets import SubplotTool

    from matplotlib import lines
    from matplotlib import cbook
    from matplotlib import verbose
    from matplotlib import rcParams

    backend_version = "%s.%s.%s" % (Gtk.get_major_version(), Gtk.get_micro_version(), Gtk.get_minor_version())

    _debug = False
    #_debug = True

    # the true dots per inch on the screen; should be display dependent
    # see http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5 for some info about screen dpi
    PIXELS_PER_INCH = 96

    cursord = {
>       cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
        cursors.HAND          : Gdk.Cursor.new(Gdk.CursorType.HAND2),
        cursors.POINTER       : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),
        cursors.SELECT_REGION : Gdk.Cursor.new(Gdk.CursorType.TCROSS),
        }
E   TypeError: constructor returned NULL

/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk3.py:55: TypeError
--------------------------------------------- Captured stderr call ---------------------------------------------

(py.test:22001): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
konstantint commented 9 years ago

I have to admit I have no clue, but apparently this has something to do with the display system. The tests are meant to run with an Agg backend, i.e. without any windows and the like, and I wouldn't be surprised if something went wrong when matplotlib insisted on using a windowing system.

I guess there can be code in the tests to force the Agg backend - I might have never gotten this error because I run tests on the server where this setting is the default anyway.

Try editing your matplotlibrc, setting backend : Agg there, and re-running py.test?

TheChymera commented 9 years ago

ahm, ok, I also tested this on one of my servers, and indeed the tests pass nicely. So it might just not be getting along with systems that are running X or something.

Sadly, I am doing all of this in my package manager sandbox, and I would very much like to avoid doing anything outside of it - so I might not be the right person to debug. Maybe you could also try to run the tests on a machine with X? I am packaging this for Gentoo, so I will definitely follow up on this issue.

konstantint commented 9 years ago

Hm, I tested this on a couple of machines with X and I cannot reproduce the problem. Setting the backend to GtkAgg did not help either. Perhaps you could make a Docker example for me to reproduce?

TheChymera commented 9 years ago

@konstantint It's ok, I think I made a mistake implementing the test phase, which just happened to blow up on my laptop but not my server.

konstantint commented 9 years ago

OK, I'll close this issue then. Thanks!

xiaoxingzeng commented 6 years ago

For some one who encount problem: "pygobject version too old -- it must have require_version" when "import matplotlib.pyplot as plt"

all you need is sudo pip uninstall matplotlib then sudo pip install matplotlib