+3 votes
in Programming Languages by (6.8k points)
edited by

I am using xgboost module in python code, but it's giving the following error. How can I fix it?

** (testxgboost.py:124281): WARNING **: Could not open X display 

(testxgboost.py:124281): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Traceback (most recent call last):
  File "testxgboost.py", line 11, in <module>
    import matplotlib.pyplot as plt
  File "/home/ravik/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/home/ravik/.local/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
  File "/home/ravik/.local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk3agg.py", line 11, in <module>
    from . import backend_gtk3
  File "/home/ravik/.local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk3.py", line 54, in <module>
    cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL

1 Answer

0 votes
by (27.1k points)

The problem seems to be related to Matplotlib, not xgboost. If you don't need matplotlib in your python code, remove import matplotlib.pyplot as plt.