Skip to content

TypeError constructor returned NULL in wayland session #19405

Closed
@liuyun88

Description

@liuyun88

Bug report

Bug summary

When trying to run matplotlib pyplot, and setting the backend to gtk3agg or gtk3cairo, the following error is encountered in wayland session. The same code works fine in Xorg, or using Qt backend.

Gdk-Message: 12:41:05.918: Unable to load fleur from the cursor theme
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/matplotlib/backends/backend_gtk3.py", line 40, in <module>
    cursors.MOVE:          Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL

Code for reproduction

import matplotlib.pyplot as plt
fig, ax0 = plt.subplots()
ax0.plot(1,1)
plt.show()

Actual outcome

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/matplotlib/backends/backend_gtk3.py", line 40, in <module>
    cursors.MOVE:          Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/yl398/test.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "/usr/lib/python3.9/site-packages/matplotlib/pyplot.py", line 2336, in <module>
    switch_backend(rcParams["backend"])
  File "/usr/lib/python3.9/site-packages/matplotlib/pyplot.py", line 276, in switch_backend
    class backend_mod(matplotlib.backend_bases._Backend):
  File "/usr/lib/python3.9/site-packages/matplotlib/pyplot.py", line 277, in backend_mod
    locals().update(vars(importlib.import_module(backend_name)))
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/lib/python3.9/site-packages/matplotlib/backends/backend_gtk3agg.py", line 8, in <module>
    from . import backend_agg, backend_gtk3
  File "/usr/lib/python3.9/site-packages/matplotlib/backends/backend_gtk3.py", line 49, in <module>
    raise ImportError(exc) from exc
ImportError: constructor returned NULL

Expected outcome

No error should be encountered and the figure should show on the screen

Matplotlib version

  • Operating system: Manjaro Linux 20.2.1
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.3.3
  • Matplotlib backend (print(matplotlib.get_backend())): GTK3AGG or GTK3Cairo
  • Python version: 3.9.1
  • Jupyter version (if applicable):
  • Other libraries:

Installed matplotlib from default manjaro/arch linux repository.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions