Debian Bug report logs - #1101565
matplotlib: missing dependency on python3-gi?

version graph

Package: src:matplotlib; Maintainer for src:matplotlib is Debian Python Team <[email protected]>;

Affects: fenics-dolfinx

Reported by: Francesco Ballarin <[email protected]>

Date: Sat, 29 Mar 2025 13:12:01 UTC

Severity: important

Tags: patch

Found in version matplotlib/3.10.1+dfsg1-2

Fixed in version matplotlib/3.10.1+dfsg1-3

Done: Alexandre Detiste <[email protected]>

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], [email protected], Debian Python Team <[email protected]>:
Bug#1101565; Package src:matplotlib. (Sat, 29 Mar 2025 13:12:02 GMT) (full text, mbox, link).


Acknowledgement sent to Francesco Ballarin <[email protected]>:
New Bug report received and forwarded. Copy sent to [email protected], Debian Python Team <[email protected]>. (Sat, 29 Mar 2025 13:12:02 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Francesco Ballarin <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: matplotlib: missing dependency on python3-gi?
Date: Sat, 29 Mar 2025 13:08:08 +0000
Source: matplotlib
Version: 3.10.1+dfsg1-2
Severity: important
X-Debbugs-Cc: [email protected]

Hi,
I am rebuilding locally the fenics-dolfinx package in a clean system, and got the following error

=====================

Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sphinx/config.py", line 529, in eval_config_file
    exec(code, namespace)  # NoQA: S102
    ~~~~^^^^^^^^^^^^^^^^^
  File "/repositories/dolfinx/python/doc/source/conf.py", line 17, in <module>
    jupytext_process.process()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/repositories/dolfinx/python/doc/source/jupytext_process.py", line 54, in process
    runpy.run_path(str(demo))
    ~~~~~~~~~~~~~~^^^^^^^^^^^
  File "<frozen runpy>", line 287, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/repositories/dolfinx/python/demo/demo_lagrange_variants.py", line 59, in <module>
    plt.plot(lattice, values[:, i])
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 3830, in plot
    return gca().plot(
           ~~~^^
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 2777, in gca
    return gcf().gca()
           ~~~^^
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 1108, in gcf
    return figure()
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 1042, in figure
    manager = new_figure_manager(
        num, figsize=figsize, dpi=dpi,
        facecolor=facecolor, edgecolor=edgecolor, frameon=frameon,
        FigureClass=FigureClass, **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 551, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 528, in _warn_if_gui_out_of_main_thread
    canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas)
                                                ~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 369, in _get_backend_mod
    switch_backend(rcParams._get("backend"))
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 411, in switch_backend
    switch_backend(candidate)
    ~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 425, in switch_backend
    module = backend_registry.load_backend_module(newbackend)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/registry.py", line 317, in load_backend_module
    return importlib.import_module(module_name)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk4agg.py", line 4, in <module>
    from . import backend_agg, backend_gtk4
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk4.py", line 19, in <module>
    gi.require_version("Gtk", "4.0")
    ^^^^^^^^^^^^^^^^^^
AttributeError: module 'gi' has no attribute 'require_version'

make[1]: *** [debian/rules:206: override_dh_auto_install-indep] Error 2


============

I noticed that, after installing python3-matplotlib, running a "import gi"
results in a "print(gi.__file__)" printing None.
If I manually install python3-gi as well, then "print(gi.__file__)" will print
the expected path of the system installation of python3-gi.

Is it possible that recent upgrade to matplotlib 3.10 missed a dependency on
python3-gi?

Cheers,
Francesco

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.12.20-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect



Added indication that 1101565 affects fenics-dolfinx Request was from Francesco Ballarin <[email protected]> to [email protected]. (Sat, 29 Mar 2025 13:18:01 GMT) (full text, mbox, link).


Information forwarded to [email protected], [email protected], Debian Python Team <[email protected]>:
Bug#1101565; Package src:matplotlib. (Sat, 29 Mar 2025 17:33:02 GMT) (full text, mbox, link).


Acknowledgement sent to Francesco Ballarin <[email protected]>:
Extra info received and forwarded to list. Copy sent to [email protected], Debian Python Team <[email protected]>. (Sat, 29 Mar 2025 17:33:02 GMT) (full text, mbox, link).


Message #12 received at [email protected] (full text, mbox, reply):

From: Francesco Ballarin <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: Re: matplotlib: missing dependency on python3-gi?
Date: Sat, 29 Mar 2025 17:31:09 +0000
Source: matplotlib
Followup-For: Bug #1101565
X-Debbugs-Cc: [email protected]
Control: severity -1 normal

The solution we adopted in fenics-dolfinx 1:0.9.0-7 is to export MPLBACKEND=agg before running sphinx.
Decreasing severity to normal.



Severity set to 'normal' from 'important' Request was from Francesco Ballarin <[email protected]> to [email protected]. (Sat, 29 Mar 2025 17:33:02 GMT) (full text, mbox, link).


Information forwarded to [email protected], Debian Python Team <[email protected]>:
Bug#1101565; Package src:matplotlib. (Mon, 31 Mar 2025 11:57:02 GMT) (full text, mbox, link).


Acknowledgement sent to James Addison <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Python Team <[email protected]>. (Mon, 31 Mar 2025 11:57:02 GMT) (full text, mbox, link).


Message #19 received at [email protected] (full text, mbox, reply):

From: James Addison <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: matplotlib: missing dependency on python3-gi?
Date: Mon, 31 Mar 2025 11:52:19 +0000
Hi Francesco,

On Sat, 29 Mar 2025 13:08:08 +0000, Francesco wrote:
> [ ... snip ... ]
> I noticed that, after installing python3-matplotlib, running a "import gi"
> results in a "print(gi.__file__)" printing None.
> If I manually install python3-gi as well, then "print(gi.__file__)" will print
> the expected path of the system installation of python3-gi.
> [ ... snip ... ]

Could you check whether any other packages (not python3-gi) had
installed files into: /usr/lib/python3/dist-packages/gi/

If so, I think that might cause the symptoms encountered here (python3
would allow gi to import as a module, but it would not contain the
python3-gi code that the matplotlib library requires)

Regards,
James



Information forwarded to [email protected], [email protected], [email protected], Debian Python Team <[email protected]>:
Bug#1101565; Package src:matplotlib. (Mon, 31 Mar 2025 12:30:01 GMT) (full text, mbox, link).


Acknowledgement sent to Francesco Ballarin <[email protected]>:
Extra info received and forwarded to list. Copy sent to [email protected], [email protected], Debian Python Team <[email protected]>. (Mon, 31 Mar 2025 12:30:01 GMT) (full text, mbox, link).


Message #24 received at [email protected] (full text, mbox, reply):

From: Francesco Ballarin <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: Re: matplotlib: missing dependency on python3-gi?
Date: Mon, 31 Mar 2025 12:27:13 +0000
Package: python3-matplotlib
Followup-For: Bug #1101565
X-Debbugs-Cc: [email protected], [email protected]

Hi James,
indeed in there I have
/usr/lib/python3/dist-packages/gi/overrides/Gedit.py
and dpkg -S /usr/lib/python3/dist-packages/gi/overrides/Gedit.py shows
gedit: /usr/lib/python3/dist-packages/gi/overrides/Gedit.py

Feel free to re-assign to gedit, or to close altogether if fixing this is not
worth the effort. We have found a reasonable solution in fenics-dolfinx, and we
are happy to keep the environment variable for future builds.

Thanks,
Francesco



Information forwarded to [email protected], Debian Python Team <[email protected]>:
Bug#1101565; Package src:matplotlib. (Mon, 31 Mar 2025 20:03:01 GMT) (full text, mbox, link).


Acknowledgement sent to James Addison <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Python Team <[email protected]>. (Mon, 31 Mar 2025 20:03:01 GMT) (full text, mbox, link).


Message #29 received at [email protected] (full text, mbox, reply):

From: James Addison <[email protected]>
To: Francesco Ballarin <[email protected]>, [email protected]
Subject: Re: Bug#1101565: matplotlib: missing dependency on python3-gi?
Date: Mon, 31 Mar 2025 20:01:16 +0000
On Mon, 31 Mar 2025 at 12:30, Francesco Ballarin
<[email protected]> wrote:
> ...
> indeed in there I have
> /usr/lib/python3/dist-packages/gi/overrides/Gedit.py
> and dpkg -S /usr/lib/python3/dist-packages/gi/overrides/Gedit.py shows
> gedit: /usr/lib/python3/dist-packages/gi/overrides/Gedit.py

Ok; thank you for checking that.  That does seem to explain the
problem, and hints at a possible workaround (removing the package(s)
that contain the overrides from the system.. not a universal
solution).

> Feel free to re-assign to gedit, or to close altogether if fixing this is not
> worth the effort. We have found a reasonable solution in fenics-dolfinx, and we
> are happy to keep the environment variable for future builds.

Multiple packages in Debian include similar gobject-introspection
overrides -- and the decision to include those files has been
discussed and is sensible[1], I think.

The code in matplot is written with the intent to detect failures to
import gobject-introspection (aka gi), and so the bug is somehow
related to both matplotlib and Debian's packaging of the override
files.

I think a path forward could be to patch the matplotlib package in
Debian so that the presence of a dist-packages/gi directory -- perhaps
only created implicitly for the overrides -- is insufficient for the
Python import of gi to be successful.

If we can write such a patch in a way that would be suitable for other
distributions (I do not know how they ship override files), then
perhaps it could also be sent upstream for their consideration.

[1] - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=754670

On Mon, 31 Mar 2025 at 12:30, Francesco Ballarin
<[email protected]> wrote:
>
> Package: python3-matplotlib
> Followup-For: Bug #1101565
> X-Debbugs-Cc: [email protected], [email protected]
>
> Hi James,
> indeed in there I have
> /usr/lib/python3/dist-packages/gi/overrides/Gedit.py
> and dpkg -S /usr/lib/python3/dist-packages/gi/overrides/Gedit.py shows
> gedit: /usr/lib/python3/dist-packages/gi/overrides/Gedit.py
>
> Feel free to re-assign to gedit, or to close altogether if fixing this is not
> worth the effort. We have found a reasonable solution in fenics-dolfinx, and we
> are happy to keep the environment variable for future builds.
>
> Thanks,
> Francesco



Information forwarded to [email protected], Debian Python Team <[email protected]>:
Bug#1101565; Package src:matplotlib. (Mon, 31 Mar 2025 21:03:02 GMT) (full text, mbox, link).


Acknowledgement sent to James Addison <[email protected]>:
Extra info received and forwarded to list. Copy sent to Debian Python Team <[email protected]>. (Mon, 31 Mar 2025 21:03:02 GMT) (full text, mbox, link).


Message #34 received at [email protected] (full text, mbox, reply):

From: James Addison <[email protected]>
To: Francesco Ballarin <[email protected]>, [email protected]
Subject: Re: Bug#1101565: matplotlib: missing dependency on python3-gi?
Date: Mon, 31 Mar 2025 21:59:48 +0100
[Message part 1 (text/plain, inline)]
On Mon, Mar 31, 2025, 21:01 James Addison <[email protected]> wrote:

> ...
> I think a path forward could be to patch the matplotlib package in
> Debian so that the presence of a dist-packages/gi directory -- perhaps
> only created implicitly for the overrides -- is insufficient for the
> Python import of gi to be successful.
>
> If we can write such a patch in a way that would be suitable for other
> distributions (I do not know how they ship override files), then
> perhaps it could also be sent upstream for their consideration.
>

Thinking about this more: your code to distinguish between
gi-imported-but-empty and gi-imported successfully could be reusable to do
exactly this.

We could patch that logic into the backend_gtk* import blocks, and raise an
ImportError if we find that the module has no file.

>
[Message part 2 (text/html, inline)]

Information forwarded to [email protected], [email protected], [email protected], Debian Python Team <[email protected]>:
Bug#1101565; Package src:matplotlib. (Tue, 01 Apr 2025 09:45:03 GMT) (full text, mbox, link).


Acknowledgement sent to James Addison <[email protected]>:
Extra info received and forwarded to list. Copy sent to [email protected], [email protected], Debian Python Team <[email protected]>. (Tue, 01 Apr 2025 09:45:03 GMT) (full text, mbox, link).


Message #39 received at [email protected] (full text, mbox, reply):

From: James Addison <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: Re: matplotlib: should fail with empty GI module (was: missing dependency on python3-gi?)
Date: Tue, 01 Apr 2025 10:40:50 +0100
[Message part 1 (text/plain, inline)]
Source: matplotlib
Followup-For: Bug #1101565
X-Debbugs-Cc: [email protected], [email protected]
Control: severity -1 important
Control: tags -1 patch

Dear Maintainer,

Please find attached a patch to resolve the problem encountered here: that the
presence of a package that installs gobject-introspection overrides[1] allows
Python / matplotlib to import the 'gi' module successfully despite the absence
of the python3-gi module that provides GObject functionality.

The fix is detects an empty/implicit module import by checking for a __file__
attribute.

I'm re-raising the severity to important, because I think many Debian systems
could have installed packages that include these overrides, and the effect on
matplotlib is non-intuitive and fairly severe.

I have tested the patch by running the following command both with and without
the patch applied, on a system that has gedit installed:

  $ python3 -c 'from matplotlib.backends import backend_gtk3'


Without the patch applied (replicating the bugreport) the result is:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
      from matplotlib.backends import backend_gtk3
    File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3.py", line 20, in <module>
      gi.require_version("Gtk", "3.0")
      ^^^^^^^^^^^^^^^^^^
  AttributeError: module 'gi' has no attribute 'require_version'


After applying the patch, the result is:

  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3.py", line 16, in <module>
      raise ImportError("Error: PyGObject module is empty")
  ImportError: Error: PyGObject module is empty
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
      from matplotlib.backends import backend_gtk3
    File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3.py", line 18, in <module>
      raise ImportError("The GTK3 backends require PyGObject") from err
  ImportError: The GTK3 backends require PyGObject


The ImportError is intended to allow matplotlib to detect that GObject is not
available on the system, so that it can choose an alternate backend
automatically.

Thanks,
James

[1] - https://wiki.gnome.org/Projects/PyGObject/IntrospectionPorting#Overrides
[fix-gi-import-empty-module.patch (text/plain, attachment)]

Severity set to 'important' from 'normal' Request was from James Addison <[email protected]> to [email protected]. (Tue, 01 Apr 2025 09:45:03 GMT) (full text, mbox, link).


Added tag(s) patch. Request was from James Addison <[email protected]> to [email protected]. (Tue, 01 Apr 2025 09:45:04 GMT) (full text, mbox, link).


Reply sent to Alexandre Detiste <[email protected]>:
You have taken responsibility. (Sat, 19 Apr 2025 16:39:01 GMT) (full text, mbox, link).


Notification sent to Francesco Ballarin <[email protected]>:
Bug acknowledged by developer. (Sat, 19 Apr 2025 16:39:01 GMT) (full text, mbox, link).


Message #48 received at [email protected] (full text, mbox, reply):

From: Debian FTP Masters <[email protected]>
To: [email protected]
Subject: Bug#1101565: fixed in matplotlib 3.10.1+dfsg1-3
Date: Sat, 19 Apr 2025 16:35:48 +0000
[Message part 1 (text/plain, inline)]
Source: matplotlib
Source-Version: 3.10.1+dfsg1-3
Done: Alexandre Detiste <[email protected]>

We believe that the bug you reported is fixed in the latest version of
matplotlib, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Alexandre Detiste <[email protected]> (supplier of updated matplotlib package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Sat, 19 Apr 2025 17:28:04 +0200
Source: matplotlib
Architecture: source
Version: 3.10.1+dfsg1-3
Distribution: unstable
Urgency: medium
Maintainer: Debian Python Team <[email protected]>
Changed-By: Alexandre Detiste <[email protected]>
Closes: 1101565
Changes:
 matplotlib (3.10.1+dfsg1-3) unstable; urgency=medium
 .
   [ James Addison ]
   * Properly detect python3-gi absence/presence (Closes: #1101565)
Checksums-Sha1:
 9f73f3d97828239ccf8be6bae91b9fbb301134ed 4065 matplotlib_3.10.1+dfsg1-3.dsc
 21b47f828eeeda41ed7856e1146b19e78f4dcd5f 41204 matplotlib_3.10.1+dfsg1-3.debian.tar.xz
 c7645a219e477b97eba3543c18cf11ec073990b9 24423 matplotlib_3.10.1+dfsg1-3_source.buildinfo
Checksums-Sha256:
 8b9d26904cce53562ff4ca559f348cfa8160f602db94a89a75ff53055e75cbde 4065 matplotlib_3.10.1+dfsg1-3.dsc
 3b44f5ef7731acddf14f228a462c7ec44b564f1c8ac10117dea99b993c17878e 41204 matplotlib_3.10.1+dfsg1-3.debian.tar.xz
 cef3655e62c020e9ed186c91fbfe17a65366adc3c0371592dfd376a7bda87c32 24423 matplotlib_3.10.1+dfsg1-3_source.buildinfo
Files:
 83f8d7d3dbd6d7e02db82dbdfb669b59 4065 python optional matplotlib_3.10.1+dfsg1-3.dsc
 4192b3d701f4ce5f5b3d85209b9d29e8 41204 python optional matplotlib_3.10.1+dfsg1-3.debian.tar.xz
 26b399361288674dbe69efaf7765e412 24423 python optional matplotlib_3.10.1+dfsg1-3_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJFBAEBCgAvFiEEj23hBDd/OxHnQXSHMfMURUShdBoFAmgDzR8RHHRjaGV0QGRl
Ymlhbi5vcmcACgkQMfMURUShdBpqLQ//bUReY5kkKh9bVag5Dr8cBHsV1TIMj8Y/
iK/RricazulroawcOCqSC/5/NY9WO9isaS7k/SJoVERSTEceWZhLNtZdvm37SNQ8
2qPIaMhCVHjAbeX48Bhq2+87TL3496xjGkTBoG9XoJhQzLn3z0cBUvMlhdy9ZSgi
y5TFU/l4Mud+KJpXqZvq+NGmT6P9c0e2uNcXcm8XwUWUCxkTK2vli4Er/mNGsNAp
geC7GvHzTOFhIGnZoBg3nUkdPsps6K/wzbf4t0zyPFfy9wNL7s/frVw5+O+fX/GX
cgLh1I/r5P9I6o4oluYk2HI1GwhhHPr3Cl22H6d7u+O+U0L9hykkSUBABt2q+wiA
ZjmwiUaIj56rUwwi6VpqkZr7ZtTcapkSx5v+hefk2N5dbxPgBLapbt8sSggJVCgG
2cQWCjhaKmKFUXUU7fqilbnFl4AR509VZtfOsqKIxZUGEttraIPdY3l3q8D2s/h0
YFCVZo0kYFTDL8zGAnz7WD6qwAz86uyjlIkn2NnVhu8Ns/nH1hvkgDPTdHqC+Be0
yPGJ+/etHLRfJ+JJJDGIFJfdtAi2eDO+VraRHhkMEtFDcIrk66aJsEB9LA91Mx8G
y6zT+xeCw/ga9l7QG6LF+XxZI5M1+kpv/tw/q8WpxzdK9ofU0DrlQ5SID/0dRwep
QFRVMAPOiKM=
=MWlV
-----END PGP SIGNATURE-----

[Message part 2 (application/pgp-signature, inline)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 15:43:18 2025; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.