From unknown Sat Aug 09 09:36:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#70687: python-matplotlib not respecting env var MPLBACKEND=TkAgg Resent-From: Jake Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 01 May 2024 01:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70687 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 70687@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171452664923290 (code B ref -1); Wed, 01 May 2024 01:25:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 May 2024 01:24:09 +0000 Received: from localhost ([127.0.0.1]:34452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1yhc-00063a-HC for submit@debbugs.gnu.org; Tue, 30 Apr 2024 21:24:08 -0400 Received: from lists.gnu.org ([2001:470:142::17]:59002) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1yhX-00063B-Fv for submit@debbugs.gnu.org; Tue, 30 Apr 2024 21:24:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1yh6-00080V-VR for bug-guix@gnu.org; Tue, 30 Apr 2024 21:23:36 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1yh3-0005Du-LY for bug-guix@gnu.org; Tue, 30 Apr 2024 21:23:36 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-51ac9c6599bso7014653e87.1 for ; Tue, 30 Apr 2024 18:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714526611; x=1715131411; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=i8wx986Jx18l++/oeSCjQWdf8hSbtOAqMUZfwcOcu3M=; b=VP1cnmsKEmaHomQUM89zl/XQMH9vICF3j6xM7SW2DxwbJuw0tuSncfSL9vmM5jC+t1 SGWhF9N2oGPYHM7HTs5aWJmogQTMghvbCza+t7R1mVYEDhEhHvg6UHYkQK1LOqZaFc7Q GHrqJf14QBSKH0ycFZ2m1Qv9XlWH3NhJp6bhU6/pmqjqCgqD5SscBiCIXFYHy1RIhnIm Z2l++KweW/6k6sGlvShy8aO1/ybSRsLaHUUsHJl7qHxDayjwga9FOBHWSOXtsx2ZWB6f ZzixwZXnCrw+Urr9UJuAOOSdDvzNndBiJFBRcR3O/Og7rVUwA5qN6rTK6WDgVW7LOLLO Qcpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714526611; x=1715131411; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=i8wx986Jx18l++/oeSCjQWdf8hSbtOAqMUZfwcOcu3M=; b=ayevxdUjB91CG75AcLSFEucLTOtGsWJ4uOc65gAgrX5F+WPtlBLUk5k+4PX6YvIuI/ kdvtaKIBIOqittGcKuXgiQke/pJ72q7aeVMzvjnx7ZZAz5lAQYlebuAeGnX5q46MqVkr +oy93TLeonenj8+F1od0uis83f48dwx5/3d9BlhYRLsN7eh42lS6//p/Ti0eVGJ+YFOS kRbeAEp0N/DYnfiQuufUhePBAGTbCubFfi4F2QjYaZ6Eh95nz3N6PpogkWbkCYc8pnqH Fr9WT9YcgVSX738/tWRe8u4wGzvKAGWPzmHr/F5A4U77Kctk5Y8dJu9O6RZrNPiyAOUy ckqA== X-Gm-Message-State: AOJu0YyLrV2qoUS0gaZpZLNb6RwrOJ/LKqH+bNJEFMd/AQVDvzizU0DI iBFP/4YFYVznrsHBGFiYhc3k11lgNo29B+kIb7cxiseHG+8//l3ElkhrwRV5cCu60aN0GzyL9Mg yG0+QtWS7lZNl8DSIbW9aaSJpHJJpngJr X-Google-Smtp-Source: AGHT+IEt6xg7+pyorx99y+/Subhz5gsDqCkXbhhB2bhbilGNO9XUQ1/8FlGLk+zW4s7JhZiAUCphKuM9vu0P1pQEE7M= X-Received: by 2002:a19:ae19:0:b0:51b:6ed6:af3f with SMTP id f25-20020a19ae19000000b0051b6ed6af3fmr628365lfc.16.1714526610468; Tue, 30 Apr 2024 18:23:30 -0700 (PDT) MIME-Version: 1.0 From: Jake Date: Wed, 1 May 2024 01:23:19 +0000 Message-ID: Content-Type: multipart/alternative; boundary="0000000000009339c806175a55e3" Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=jforst.mailman@gmail.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --0000000000009339c806175a55e3 Content-Type: text/plain; charset="UTF-8" Hello We are supposed to be able to control the backend used by Python's Matplotlib via the MPLBACKEND environment variable [1]. This doesn't appear to work for the TkAgg backend: #+begin_src sh guix shell python python-matplotlib -- bash -c 'MPLBACKEND=TkAgg python3 -c "import matplotlib; print(matplotlib.get_backend()); import matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()"' #+end_src #+RESULTS: : TkAgg : :1: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown However, the TkAgg backend does work if it is hardcoded in the Python script using `matplotlib.use()`: #+begin_src sh guix shell python python-matplotlib -- python3 -c "import matplotlib; matplotlib.use('TkAgg'); print(matplotlib.get_backend()); import matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()" #+end_src #+RESULTS: : TkAgg Thanks Jake [1]: https://matplotlib.org/stable/users/explain/figure/backends.html --0000000000009339c806175a55e3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello

We are supposed to be able to control th= e backend used by Python's Matplotlib via the MPLBACKEND environment va= riable [1]. This doesn't appear to work for the TkAgg backend:
#+begin_src sh

=C2=A0 guix shell python python-matplotlib -- bash -= c 'MPLBACKEND=3DTkAgg python3 -c "import matplotlib; print(matplot= lib.get_backend()); import matplotlib.pyplot as plt; plt.plot([1],[2]); plt= .show()"'

#+end_src

#+RESULTS:
: TkAgg
: <s= tring>:1: UserWarning: FigureCanvasAgg is non-interactive, and thus cann= ot be shown

However, the TkAgg backend does work if it is hardcoded = in the Python script using `matplotlib.use()`:

#+begin_src sh
=C2=A0 guix shell python python-matplotlib -- python3 -c "import matp= lotlib; matplotlib.use('TkAgg'); print(matplotlib.get_backend()); i= mport matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()"

= #+end_src

#+RESULTS:
: TkAgg

--0000000000009339c806175a55e3-- From unknown Sat Aug 09 09:36:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#70687: python-matplotlib not respecting env var MPLBACKEND=TkAgg Resent-From: Jake Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 03 Apr 2025 11:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70687 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 70687@debbugs.gnu.org Cc: me@bonfacemunyoki.com, sharlatanus@gmail.com, tanguy@bioneland.org, lars@6xq.net Received: via spool by 70687-submit@debbugs.gnu.org id=B70687.17436802327759 (code B ref 70687); Thu, 03 Apr 2025 11:38:02 +0000 Received: (at 70687) by debbugs.gnu.org; 3 Apr 2025 11:37:12 +0000 Received: from localhost ([127.0.0.1]:33066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u0Ish-000215-N4 for submit@debbugs.gnu.org; Thu, 03 Apr 2025 07:37:12 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:57710) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u0Ise-00020W-3u for 70687@debbugs.gnu.org; Thu, 03 Apr 2025 07:37:09 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-39ac9aea656so678273f8f.3 for <70687@debbugs.gnu.org>; Thu, 03 Apr 2025 04:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743680221; x=1744285021; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=HoKEkubbco/nSI9fbtNIzBGt6Bg67QIEqSLn9kNTPV4=; b=mFnVushSRPwOXAmeV7aX7HAvoTjdgJBTb2wdkM7cLGupcq8+010UaTCpTe7NRYD/bW jw+a5vWw7obE3EVIzxtAlCShULOo8COghWwZ2YBRYEiT9vIineIuHvbrr8+5oFn3qBcj Ig/2+pGICDeMCH/2aDybPdG5QqXyFBvXWes9PAl5GZUB/BlwLa5RsYpta9JbHM7iGxge kH0lcdYQg0YjkQdxny1UY8Ni/ofSzDZPLktpZoItfLqigii4yPt2Kjgf9dOURYqMA/oN XQwcLARI3D4YoU3lB/kJYZ0Y+JsKZzaIc+v8Sps+XeCZSgd0LFEGJlgMECNfBGH8Rp1u YPZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743680221; x=1744285021; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HoKEkubbco/nSI9fbtNIzBGt6Bg67QIEqSLn9kNTPV4=; b=TD0AcAQSjFwScBUkA4F1FJ/Hk7JviKCtBxopAilvvnfH7FqOVRqtJve6WZAH2LUFDJ Zh9xxevJNxc4wEMw9Sq6D3FLxXegOPs6VFggITkfDDwYFev0rR07uEobI6pdUG2SQSgE XSEaq+k7onwFaodHXFG/wJiJzr8WUMXNd0vZ9x/7vpxaREpFu8LSCTbRWamqVuUxzeny pQvbk6td50qupA3zMwznh6nGDo/xnyfdC+c+aqDAs1xcEdDJjZBp4sMjLC7x1y/sGrDe fxOU4eI/ffhH+o+31t/1pxvMr2BKNTCUOdQbG57tTtKbTLTJH0YSlS+Uvp0LybirELHa 8wvQ== X-Gm-Message-State: AOJu0YzFkgukUqJeogpEJ1Xcqd1+TrFwhLeuQ45qgsOaWh8C+yVEtwaP F/CfCI46yfRTJ+kSHYCgCvJBwnuolZml9FetYIghFahCVcmnndbnj+WwW2QlJkAC37ioxhtFcRE YiKt6sc98KvXhzNtS0V18hFtl+PTU32/c X-Gm-Gg: ASbGncsfTqVXpRqcdtFsDB0G1DaOb1WeFfRqBfMid5EovQWuYaQOM4sjRH8qD829Xn1 q6qMNCHcNGltEDpX747gND6/fuHnSVr6s7xYqEbUkaYBEdDjUSGu4hx7YM8SPS8tVmHHTz64Egq LZFXS3ysfP09qjBx4oekCCNuqIylQseMMkj2Im X-Google-Smtp-Source: AGHT+IG+/M3vxMeAhGNEP0DxRQN+FO/PzeFSS0BfJvjNvPg/+0ZoLoJEkYK7qMI4WSzRNo9CFtq9rX2EZPLpHI2iPnQ= X-Received: by 2002:a5d:5f4d:0:b0:399:737f:4e02 with SMTP id ffacd0b85a97d-39c12117cb2mr17168360f8f.39.1743680220612; Thu, 03 Apr 2025 04:37:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jake Date: Thu, 3 Apr 2025 11:36:49 +0000 X-Gm-Features: ATxdqUHL7uhDRwbR7WW-EdfcHj4JbwO01GoiJXifEvXYTQCjWK4hw61O2W3z5QE Message-ID: Content-Type: multipart/alternative; boundary="00000000000026d04a0631de300a" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --00000000000026d04a0631de300a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It appears that importing matplotlib.pyplot resets the Matplotlib backend to Agg. $ guix shell python python-matplotlib -- bash -c 'MPLBACKEND=3Dtkagg python3 -c "import matplotlib; print(matplotlib.get_backend()); import matplotlib.pyplot; print(matplotlib.get_backend())"' TkAgg agg On Wed, May 1, 2024 at 1:25=E2=80=AFAM Jake wrot= e: > Hello > > We are supposed to be able to control the backend used by Python's > Matplotlib via the MPLBACKEND environment variable [1]. This doesn't appe= ar > to work for the TkAgg backend: > > #+begin_src sh > > guix shell python python-matplotlib -- bash -c 'MPLBACKEND=3DTkAgg pyth= on3 > -c "import matplotlib; print(matplotlib.get_backend()); import > matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()"' > > #+end_src > > #+RESULTS: > : TkAgg > : :1: UserWarning: FigureCanvasAgg is non-interactive, and thus > cannot be shown > > However, the TkAgg backend does work if it is hardcoded in the Python > script using `matplotlib.use()`: > > #+begin_src sh > > guix shell python python-matplotlib -- python3 -c "import matplotlib; > matplotlib.use('TkAgg'); print(matplotlib.get_backend()); import > matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()" > > #+end_src > > #+RESULTS: > : TkAgg > > Thanks > Jake > > [1]: https://matplotlib.org/stable/users/explain/figure/backends.html > --00000000000026d04a0631de300a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It appears that importing matplotlib.pyplot resets th= e Matplotlib backend to Agg.

=C2=A0 $ guix shell python python-matplotlib -- bash -c 'MPLBACKEND=3Dtkagg= =20 python3 -c "import matplotlib; print(matplotlib.get_backend()); import= matplotlib.pyplot; print(matplotlib.get_backend())"'
=C2=A0 TkAgg
=C2=A0 agg


On W= ed, May 1, 2024 at 1:25=E2=80=AFAM Jake <jforst.mailman@gmail.com> wrote:
Hello

We = are supposed to be able to control the backend used by Python's Matplot= lib via the MPLBACKEND environment variable [1]. This doesn't appear to= work for the TkAgg backend:

#+begin_src sh

=C2=A0 guix she= ll python python-matplotlib -- bash -c 'MPLBACKEND=3DTkAgg python3 -c &= quot;import matplotlib; print(matplotlib.get_backend()); import matplotlib.= pyplot as plt; plt.plot([1],[2]); plt.show()"'

#+end_src
#+RESULTS:
: TkAgg
: <string>:1: UserWarning: FigureCanvas= Agg is non-interactive, and thus cannot be shown

However, the TkAgg = backend does work if it is hardcoded in the Python script using `matplotlib= .use()`:

#+begin_src sh

=C2=A0 guix shell python python-matpl= otlib -- python3 -c "import matplotlib; matplotlib.use('TkAgg'= ); print(matplotlib.get_backend()); import matplotlib.pyplot as plt; plt.pl= ot([1],[2]); plt.show()"

#+end_src

#+RESULTS:
: TkAgg=

Thanks
Jake

--00000000000026d04a0631de300a-- From unknown Sat Aug 09 09:36:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#70687: python-matplotlib not respecting env var MPLBACKEND=TkAgg Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 05 Apr 2025 23:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70687 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Jake , 70687@debbugs.gnu.org Cc: me@bonfacemunyoki.com, tanguy@bioneland.org, sharlatanus@gmail.com, lars@6xq.net Received: via spool by 70687-submit@debbugs.gnu.org id=B70687.17438940555716 (code B ref 70687); Sat, 05 Apr 2025 23:01:01 +0000 Received: (at 70687) by debbugs.gnu.org; 5 Apr 2025 23:00:55 +0000 Received: from localhost ([127.0.0.1]:45256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1CVS-0001U8-Qu for submit@debbugs.gnu.org; Sat, 05 Apr 2025 19:00:55 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:49590) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u1CVQ-0001Tq-GI for 70687@debbugs.gnu.org; Sat, 05 Apr 2025 19:00:53 -0400 Received: by mail-wm1-x342.google.com with SMTP id 5b1f17b1804b1-43cec5cd73bso16546725e9.3 for <70687@debbugs.gnu.org>; Sat, 05 Apr 2025 16:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743894046; x=1744498846; darn=debbugs.gnu.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=1AFPbC8DKdetjBdmTNePdPeBEw6Y6tgwiXCQUD0zlms=; b=Jw7LVE0Nk1ZqxPbwr7rHk2j2I4fi5derDOKnnFsFXjU9Wrz08HIfQ3oJ2ig7tkEzro sn+yWgoUyzMrKFUDBjAmVquaGDEejZXwF4V2jXABMuSoK4dbcEjo5F7fsIXcbiBx95lE 0LBg0kCXmoXKmoZAXsb9mjp02erSWlqWN4TJH5APey3G73H6Jgs5G91OY3yLsD+FJW1Z n5qNhHCk9xQdX8bVFNFl36zFA74x6Izir57Hw5vp5F2RnvH/IxoTWMHv3rJHzvYUvTJ2 MFe/YFytVDAc0nX9+Uv3gX2p1dpciIFSmTNZOZjew0+gM6fu/nnS2QjhqLHrCvVQXHN5 MfFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743894046; x=1744498846; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1AFPbC8DKdetjBdmTNePdPeBEw6Y6tgwiXCQUD0zlms=; b=e5kvX33N9OJnAKreiAHEwfLQLAAkesph/zyDPDKqhydEa6Pc+lCNIX5uWmt4/6s8+K 9Aye3vEjE6Hc1aCCqMSUqVD2v74wtKQWGphjVQQHcU1VhpQwrOT5YOoFVNhrxbSRNZNk EWD9vZpqGnPc7wozes05LSW6CLKWg6DiTQQXncqWrRWS8d7NrsV9ND1FFKTfY97dN6jb /ZDLYN6UywDuky3DG5KQv58DWI6FisHI4uEshP7O2J9tI6/CpcCOdsLXTArb/LbT0r1n Q6nA0ZTVaom1F3EIfNoJYmYqG3rnYZfoqNVplSt7VPiucMF4IYB7MFZF6HCxuquyzm3w HysQ== X-Forwarded-Encrypted: i=1; AJvYcCWvEeX8HmKbNCBCQjo3E3vFcvhdPrjIvvQw4im1CLaf37CN9ekrcvvsYVmiT2arwPkaI27oMg==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzsaVgVTX0uIOQCSZjp9Xg2uOS/B+b3xycS5gvXZZoB/beLSAEs mmHArFV3eh+/GMmFJlbrh7SdZt6yfpvF0Y0GSOHBvHbSHKK4KXcr X-Gm-Gg: ASbGnctB/TR+V7UYBoi2Or13s2HHJN3gxdi29J+3j9Oi5PDBKsJLtkgjKMeAQuowjB7 X0NDuBA9zSwgYgLtDftXgT2hVhQ/zsPeFWs/jC08eEjNgwZ/v+0w96htfQhMSQGsxZDELPhejgL Sm9AMoV7M0bLNR+eJhCyYg53ZYkwTaFPSdCFskZ1Cs65nKngATvu2ZIAxiYoK+1VaoZI4Kla7u2 FWFcCf4LPQtaBB+5JhzK+bcBwk5d5IzJr3p0tFRXmqQtLI5MxyuF5cSt6+ZDqZNz+gmoRKfZwz6 TSKfdQCHfPXhkXdHQg8EOSIuFxoUvQTNMaL/K/o9K4ZSYYnxrxsOiFwSwAqC4GznDW57MQxODKC fWtqYSO1PTR5XxdF6RtBFs4qwm/5bDCE= X-Google-Smtp-Source: AGHT+IGqZlGpHC7W8XY2k7H4QNQLhLOf4TqSuf/ZBC3f8JDMEb6sJIF+/D662M/O9608OJwAt+zBtQ== X-Received: by 2002:a05:600c:1d88:b0:43c:ea40:ae4a with SMTP id 5b1f17b1804b1-43ee0783f84mr39701395e9.31.1743894045921; Sat, 05 Apr 2025 16:00:45 -0700 (PDT) Received: from lumine.fritz.box (85-127-114-32.dsl.dynamic.surfer.at. [85.127.114.32]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43ea8d16d35sm105505755e9.0.2025.04.05.16.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Apr 2025 16:00:45 -0700 (PDT) Message-ID: <1608a77ee8cb2d6de27bc1fa4a1d79115fb9ef46.camel@gmail.com> From: Liliana Marie Prikler Date: Sun, 06 Apr 2025 01:00:44 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Jake, Am Donnerstag, dem 03.04.2025 um 11:36 +0000 schrieb Jake: > It appears that importing matplotlib.pyplot resets the Matplotlib > backend to Agg. >=20 > =C2=A0 $ guix shell python python-matplotlib -- bash -c 'MPLBACKEND=3Dtka= gg > python3 -c "import matplotlib; print(matplotlib.get_backend()); > import matplotlib.pyplot; print(matplotlib.get_backend())"' >=20 > =C2=A0 TkAgg > =C2=A0 agg I recently encountered the same issue. The issue is that matplotlib internally sources a configuration file that sets the backend *after* reading the environment variable. To circumvent this, you use something along the lines of the following code until the issue is fixed: from matplotlib import set_backend=20 from os import environ =20 [=E2=80=A6] if __name__ =3D=3D '__main__': if 'MPLBACKEND' in environ: set_backend(environ['MPLBACKEND']) [=E2=80=A6] Cheers From unknown Sat Aug 09 09:36:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#70687: python-matplotlib not respecting env var MPLBACKEND=TkAgg Resent-From: Jake Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 03 Jul 2025 13:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70687 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Liliana Marie Prikler Cc: me@bonfacemunyoki.com, 70687@debbugs.gnu.org, tanguy@bioneland.org, sharlatanus@gmail.com, lars@6xq.net Received: via spool by 70687-submit@debbugs.gnu.org id=B70687.175154882027433 (code B ref 70687); Thu, 03 Jul 2025 13:21:01 +0000 Received: (at 70687) by debbugs.gnu.org; 3 Jul 2025 13:20:20 +0000 Received: from localhost ([127.0.0.1]:47334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uXJrP-00077Y-Cv for submit@debbugs.gnu.org; Thu, 03 Jul 2025 09:20:19 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:51360) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uXJrL-000723-D5 for 70687@debbugs.gnu.org; Thu, 03 Jul 2025 09:20:16 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4538bc52a8dso56408375e9.2 for <70687@debbugs.gnu.org>; Thu, 03 Jul 2025 06:20:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751548809; x=1752153609; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q4g0STkhgORhqEV1K+oF6aBbma/a1f/Nx7cMDv6t2Ts=; b=Cu6g9LdnDJ56s1O8sZ37maiFmiDcpx0Rll8eU6ettU4M3Xq6rh+SjggX6fc1QL7Nuf SY0ss6lIERViJGbQi1H0psA+iyjD3iEX4wtII3K09fDcodtHFBW9gBa/qLi23mLMW6hM 6aurbbXXnYmwcwESixOt5zN9AxoRrNb2YDHxIBHnoC35+UFMjbkD+nBkKSQH4xP5H9uI SqC4uZIa9FRLmsO+mZzlWFmqamf+6ub+hJUTdGmKGX8fDaGlm+UNTK1FZxJAWBVMxBqR iMhqkcfZuUkZlQ07nb5+4WAkB8WqIHgnKqysJfI/yYRinR3cmReCTm+6C+QurZdbdmQW mNtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751548809; x=1752153609; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q4g0STkhgORhqEV1K+oF6aBbma/a1f/Nx7cMDv6t2Ts=; b=t93tNS6dVajgMMR/FU7m1z1k/KaUr1b5K0WHh+LqOZiJsAWxKHQhIYrvMS1Fyp8iEq z3ecWVtDbCGyfULv92uDuQZZ+DoD+KGOIFM2zQYpF2J8xgWfImjQMFsg1Ad5ZhxLwriQ mkB1kIHC1k4JzMFbxD44Xt9IM0PT+1q82ZUpcbIosmya50ob8dlZAnLDqH87Iox+5jix WrfCwEmYcwJLa8gz0+dEY+uJYKwPlYtsFImtcaU4AEH0Nz/dl/ittukgR+a35ZxzW1wh T+I+930r+IVrEU3qPrAYVoMB2yLLb6a1ExgFj1TMLoPLKGA8QQ1M55IxEEoCINOy+mu4 WCnw== X-Gm-Message-State: AOJu0YzjkSM6EmxTAiEdubX+Oqr2Eg7J3louIjGtizkP9o3u+ZbYUP6w UibKIB8En0eKOfKyV+r2Rs6lkNZUIWQw8wJRcdiHGFhxCmc1UUxVAnuXdirHtyRnScfY+zPsfSE luZzJHhIWwasPjEjpJfAfONZFWpfYShw= X-Gm-Gg: ASbGnctaKcfpG/ppeHU7CEpfEcGPa5TE5XZJC/MxbedcUwJ//44y8/Ek2kzf7lTjE61 16dR8IsbO5wEUY1vrRs2TxntXjAngDLrqwXMMzbFx0nKexOK/9s7PFKVhxZlgxIiXETfp+po+Zi UiOmwbg0161qMfT+UGOpr6kIqS0M6Qq7fui6TZZwfHhj4= X-Google-Smtp-Source: AGHT+IFJPrrqpAxZjhfionNE/2XVtwTgsosps+olVCVsvsMF16Fal9XpDIyb/JGKCNAXC/ElIiWUZx0Ev4WzbOTiYlg= X-Received: by 2002:a05:600c:c4a5:b0:43d:b3:fb1 with SMTP id 5b1f17b1804b1-454a9cd8f6emr33608975e9.27.1751548808542; Thu, 03 Jul 2025 06:20:08 -0700 (PDT) MIME-Version: 1.0 References: <1608a77ee8cb2d6de27bc1fa4a1d79115fb9ef46.camel@gmail.com> In-Reply-To: <1608a77ee8cb2d6de27bc1fa4a1d79115fb9ef46.camel@gmail.com> From: Jake Date: Thu, 3 Jul 2025 13:19:54 +0000 X-Gm-Features: Ac12FXykQsAYlhqWA3ECPk3ofSbhUCggM4vkkJLEtVoLaaGkV4Zbcp4dcD6WwQ4 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Lily It looks like this bug isn't going away anytime soon. Here is the offending code in `lib/matplotlib/pyplot.py`, with an added print statement: ```text # If rcParams['backend_fallback'] is true, and an interactive backend is # requested, ignore rcParams['backend'] and force selection of a backend th= at # is compatible with the current running interactive framework. if (rcParams["backend_fallback"] and rcParams._get_backend_or_none() in ( # type: ignore set(rcsetup.interactive_bk) - {'WebAgg', 'nbAgg'}) and cbook._get_running_interactive_framework()): # type: ignore print(f"running interactive framework is: {cbook._get_running_interactive_framework()}") rcParams._set("backend", rcsetup._auto_backend_sentinel) # type: ignor= e ``` Running this ```text MPLBACKEND=3Dtkagg guix shell --with-source=3Dpython-matplotlib=3D$HOME/matplotlib --without-tests=3Dpython-matplotlib python python-matplotlib -- python3 -c "import matplotlib; print(matplotlib.get_backend()); import matplotlib.pyplot as plt; print(matplotlib.get_backend())" ``` gives ```text TkAgg running interactive framework is: headless agg ``` So I guess the next question is: why does it think I'm headless? To be continued... Thanks Jake On Sat, Apr 5, 2025 at 11:00=E2=80=AFPM Liliana Marie Prikler wrote: > > Hi Jake, > > Am Donnerstag, dem 03.04.2025 um 11:36 +0000 schrieb Jake: > > It appears that importing matplotlib.pyplot resets the Matplotlib > > backend to Agg. > > > > $ guix shell python python-matplotlib -- bash -c 'MPLBACKEND=3Dtkagg > > python3 -c "import matplotlib; print(matplotlib.get_backend()); > > import matplotlib.pyplot; print(matplotlib.get_backend())"' > > > > TkAgg > > agg > I recently encountered the same issue. The issue is that matplotlib > internally sources a configuration file that sets the backend *after* > reading the environment variable. To circumvent this, you use > something along the lines of the following code until the issue is > fixed: > > from matplotlib import set_backend > from os import environ > > [=E2=80=A6] > > if __name__ =3D=3D '__main__': > if 'MPLBACKEND' in environ: set_backend(environ['MPLBACKEND']) > [=E2=80=A6] > > Cheers From unknown Sat Aug 09 09:36:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#70687: python-matplotlib not respecting env var MPLBACKEND=TkAgg Resent-From: Jake Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 03 Jul 2025 13:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70687 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Liliana Marie Prikler Cc: me@bonfacemunyoki.com, 70687@debbugs.gnu.org, tanguy@bioneland.org, sharlatanus@gmail.com, lars@6xq.net Received: via spool by 70687-submit@debbugs.gnu.org id=B70687.17515505298278 (code B ref 70687); Thu, 03 Jul 2025 13:49:02 +0000 Received: (at 70687) by debbugs.gnu.org; 3 Jul 2025 13:48:49 +0000 Received: from localhost ([127.0.0.1]:47783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uXKIx-00029D-Mx for submit@debbugs.gnu.org; Thu, 03 Jul 2025 09:48:49 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:43427) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uXKIt-00027f-PV for 70687@debbugs.gnu.org; Thu, 03 Jul 2025 09:48:44 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-454ac069223so4198135e9.1 for <70687@debbugs.gnu.org>; Thu, 03 Jul 2025 06:48:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751550517; x=1752155317; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0hlBG/D61tVXF5ZFDKCGhyJjF0h81JVqMI72aLWjfTc=; b=SMTwPrrAlDEmf00/LNBcwDe3siafrefoliwr7Tfnb0fCcjvaCqixUY7+6Q0P5BSpvn Qu9NtzO4QINaVKWXCAdcT0Q27CC9ubNmYqq+Z2JpSnZtaXuYHMu9FuIFPohux/KQqQep s83PQ+RmYaONxmPaaI1H4ZHli6ZF8hp+UUYO7RAo4hpZ4ZLKKy4eGbnRmxgLMoLBxa5c 0bIclaH+BTK3MeDJKFkY86EHfFQkFxNY/+Ef1f2obQe+T32lTJhdT20EfUav3qJRlNMj wVrJvT3DTY+Cgg8k5r1WJU5Yye/GNrTeNsc10ALmddVznqhfFimfHM0TuyQV7+D/g4R6 YaBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751550517; x=1752155317; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0hlBG/D61tVXF5ZFDKCGhyJjF0h81JVqMI72aLWjfTc=; b=JwGcnZ2DJFGlz9fyx2I5HakJolH35Wdp4/FAdPDyEyj6MhdLOInzTUR/DFwLyhVmnX emLtW4FvZUdxFFLu/hLgkc7g8sUmZZNgS+vHem+ToYY2v13wzd5+vTl/TuIytouBRY9u 9pUWT14M84GJgPklmGIViVmZVyb4VivLdDsNJgL4Wo3B6xnYM9OBYsAdZYu3BnwMKQWI E9pyPBOavPW5C08Xv3ERm1IeOtKXEHtFpf6PIYGnw3mebb36jULdq2BiCUyrJVtlaLXm Vcw4vZNsldpYMVFZLPcwKmlc/rCCmeP32vVWmWy314H+9ihQs/sMHmaeoTbK19LW7u8J JmHg== X-Gm-Message-State: AOJu0YyXIAUkgMfWRLbaR9bjarJZGB8NbMLhs0IFiRqh/TRUEeW6OcYY kgT5TfNB2dEIa+UqWoXR8d5ABf19wOKot9otdxTFpSZWZmVdV44WJd9WQoiSIphpaBvPoThDJHP 0S7vfSad8ePMDF2/a2E4l92TypuK8gLQ= X-Gm-Gg: ASbGncspWxtcmXuowHVovz/n/cXzfQTm8dAVVcvxCQxywPWpDX0TykHaqE292iJDgj4 wME3wxAqUbnAL/8EsZ8wLokiIfsENNw9426kJ2wv/mRHmkEBbppio7hQtM7NLhsyhMrdZ8MO99W d0ieOUEHCftslH7nEKInjYMfmIIcdVr2gp3ULUkqjZLJ4= X-Google-Smtp-Source: AGHT+IFCe6DNnz5nQ6sr2Gvklh4+78xZYGWERRdFoxpAvwcaQYRnkYDvm8jwh1RpS9WSBw+GjKiRF5iRGVlCkXK/CgU= X-Received: by 2002:a05:600c:c170:b0:442:f904:1305 with SMTP id 5b1f17b1804b1-454ab3200f4mr27297215e9.6.1751550517058; Thu, 03 Jul 2025 06:48:37 -0700 (PDT) MIME-Version: 1.0 References: <1608a77ee8cb2d6de27bc1fa4a1d79115fb9ef46.camel@gmail.com> In-Reply-To: From: Jake Date: Thu, 3 Jul 2025 13:48:25 +0000 X-Gm-Features: Ac12FXzv3fK2BAgMy7aYtJVGM-uuzFfrZPJ6vykKerNb_Uf74RCVLdPRZfSlrMc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Continuing: In `lib/matplotlib/cbook.py`, the function `_get_running_interactive_framework` has: ```text if not _c_internal_utils.display_is_valid(): return "headless" ``` In `src/_c_internal_utils.c` we have this docstring for `display_is_valid`: ```text "Check whether the current X11 or Wayland display is valid.\n\n" "On Linux, returns True if either $DISPLAY is set and XOpenDisplay(NUL= L)\n" "succeeds, or $WAYLAND_DISPLAY is set and wl_display_connect(NULL)\n" "succeeds.\n\n" "On other platforms, always returns True."}, ``` $DISPLAY is set, so it must be XOpenDisplay(NULL) failing... I found a post [1] from a Nix user: > For anyone else facing similar issues - I resolved this by adding the X11= library to the LD_LIBRARY_PATH of my development shell. But I haven't made any more progress. Cheers Jake [1] https://discourse.nixos.org/t/python-matplotlib-tkinter-matplotlib-reve= rts-to-agg-backend-because-it-cant-find-a-valid-display/45064 On Thu, Jul 3, 2025 at 1:19=E2=80=AFPM Jake wrot= e: > > Hi Lily > > It looks like this bug isn't going away anytime soon. > > Here is the offending code in `lib/matplotlib/pyplot.py`, with an > added print statement: > > ```text > # If rcParams['backend_fallback'] is true, and an interactive backend is > # requested, ignore rcParams['backend'] and force selection of a backend = that > # is compatible with the current running interactive framework. > if (rcParams["backend_fallback"] > and rcParams._get_backend_or_none() in ( # type: ignore > set(rcsetup.interactive_bk) - {'WebAgg', 'nbAgg'}) > and cbook._get_running_interactive_framework()): # type: ignore > print(f"running interactive framework is: > {cbook._get_running_interactive_framework()}") > rcParams._set("backend", rcsetup._auto_backend_sentinel) # type: ign= ore > ``` > > Running this > > ```text > MPLBACKEND=3Dtkagg guix shell > --with-source=3Dpython-matplotlib=3D$HOME/matplotlib > --without-tests=3Dpython-matplotlib python python-matplotlib -- python3 > -c "import matplotlib; print(matplotlib.get_backend()); import > matplotlib.pyplot as plt; print(matplotlib.get_backend())" > ``` > > gives > > ```text > TkAgg > running interactive framework is: headless > agg > ``` > > So I guess the next question is: why does it think I'm headless? To > be continued... > > Thanks > Jake > > > On Sat, Apr 5, 2025 at 11:00=E2=80=AFPM Liliana Marie Prikler > wrote: > > > > Hi Jake, > > > > Am Donnerstag, dem 03.04.2025 um 11:36 +0000 schrieb Jake: > > > It appears that importing matplotlib.pyplot resets the Matplotlib > > > backend to Agg. > > > > > > $ guix shell python python-matplotlib -- bash -c 'MPLBACKEND=3Dtkag= g > > > python3 -c "import matplotlib; print(matplotlib.get_backend()); > > > import matplotlib.pyplot; print(matplotlib.get_backend())"' > > > > > > TkAgg > > > agg > > I recently encountered the same issue. The issue is that matplotlib > > internally sources a configuration file that sets the backend *after* > > reading the environment variable. To circumvent this, you use > > something along the lines of the following code until the issue is > > fixed: > > > > from matplotlib import set_backend > > from os import environ > > > > [=E2=80=A6] > > > > if __name__ =3D=3D '__main__': > > if 'MPLBACKEND' in environ: set_backend(environ['MPLBACKEND']) > > [=E2=80=A6] > > > > Cheers From unknown Sat Aug 09 09:36:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#70687: python-matplotlib not respecting env var MPLBACKEND=TkAgg Resent-From: Jake Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 04 Jul 2025 08:10:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70687 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Liliana Marie Prikler Cc: me@bonfacemunyoki.com, 70687@debbugs.gnu.org, tanguy@bioneland.org, sharlatanus@gmail.com, lars@6xq.net Received: via spool by 70687-submit@debbugs.gnu.org id=B70687.175161657429643 (code B ref 70687); Fri, 04 Jul 2025 08:10:03 +0000 Received: (at 70687) by debbugs.gnu.org; 4 Jul 2025 08:09:34 +0000 Received: from localhost ([127.0.0.1]:56566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uXbUD-0007hz-2L for submit@debbugs.gnu.org; Fri, 04 Jul 2025 04:09:34 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:61840) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uXbUA-0007gq-Sl for 70687@debbugs.gnu.org; Fri, 04 Jul 2025 04:09:32 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-454aaade1fbso6643455e9.3 for <70687@debbugs.gnu.org>; Fri, 04 Jul 2025 01:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751616564; x=1752221364; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2k3uMZ0k2NZ7fLueftR3TD9B22Kqw1HqaebOOU9a5HI=; b=Vm2n6iXuwzW3OnSlWr/GFTozxsyn5iivbnWd1lFKvbj8yb4nwx8UDWLDt/CUtNfzii OoACNPdvKrmtKqshnXQpVaCJNduNsXU8tZsruBeLb4Hy7gmLYZ3MLhn07T0JVzY5eABD zjC/ARpLtgPJ6+jlkXHuwWBq5B1C1V/CZswPOxduO3/CpQ/eGpXYEeFF4Kcc/209lVcX RbQB125MtffXXIZJyrNRoa7fm17U+BpOdDRz75dhvsPwDqB4g/2NbU0ItWJAp8+TmH3l kBTI9/hpDXRJk+DAJCi4ISM3SFuF+kfh5zyrSgBtGW4qAq1Tzh2jLUw7YrV0Vlc6YOEa adkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751616564; x=1752221364; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2k3uMZ0k2NZ7fLueftR3TD9B22Kqw1HqaebOOU9a5HI=; b=UeJn/hQnlX0+O+8Z3bE88ykKjzEvMFs6CjBY0u89utx1k5DTqbhKZKV2PFdPE33ZHz AuBXYtOKe9YT8MRHQ5BYLOjTLEIPVoVWxJWfqTA0TLaYDAJgRsbp6Cx4iWMwQlni+NkR fqxgeng32uEC4+4Zlo9OCGxzKNVyui5wVkujnKQNxg6l9usO/rTU105WIV/O4YUY6YpN hcjTsACnOkq782+UFtvDmLHoyobs9EKeC+unsffkiZ1D+wUY+Tc1EmLVUHZ2AczCp1mK XXHGxNDMJLFNaPmmSw0Xjza/ba73z3h/Y11dJgeZC+2g/0GIcZBt2VMKr9pU09VY0tcN cLeA== X-Gm-Message-State: AOJu0YxHLJDSz0W0Hnq/FeSDNgnzgZ/fIw1TCCn7xhFJ05c17qroAZ+8 W48aiNAZWg8kOr6P9vJWYquAmfYtdwIoGU/1l4hSMAp0lGVEsRSbmhMT1BtGihroj9Q82FkZotP tGIcrY5fEaohebmacGHIoHAahydZk/5Y= X-Gm-Gg: ASbGncsteXQn7371efBQ7WGAR9QadPFucyKiKsRJzWuEvK2/r1KP1/tfPXoKMyTaVhn pi1d8R6crzGmd+3lOIwTja0xNsUe7lmBilfg+QjcpJi2LmLWMadsfs7urlJGwkM5PB3i3LiGFlC LqOXvHmX/lOvuaBgGn7b9a2Chx6Y14uprWRXbOiq2BxMA= X-Google-Smtp-Source: AGHT+IGa1Rwyo9+IBnC8BvjoMeBk64okeLDKdwv/YYNY3JSBFTnQYS3qjseidSffKG0NrsafsF1O+gKw0JkUkqpRqfQ= X-Received: by 2002:a05:600c:1c94:b0:43c:ec97:75db with SMTP id 5b1f17b1804b1-454b4e79819mr9847795e9.11.1751616564018; Fri, 04 Jul 2025 01:09:24 -0700 (PDT) MIME-Version: 1.0 References: <1608a77ee8cb2d6de27bc1fa4a1d79115fb9ef46.camel@gmail.com> In-Reply-To: From: Jake Date: Fri, 4 Jul 2025 17:39:13 +0930 X-Gm-Features: Ac12FXwwesiR7CK1jV0GUuBZNni4oUatYqGyn3OLIqmdrfaBr2vj1d3Fl6RpdZE Message-ID: Content-Type: multipart/alternative; boundary="00000000000014c44b06391603df" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --00000000000014c44b06391603df Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Fixed, I think. We just need to patch a dlopen call. Now TkAgg works out of the box, without requiring changes to user Python code. I hope that also means we can change the default backend from Agg to TkAgg. Submitted this PR (and got lucky number 1000!) https://codeberg.org/guix/guix/pulls/1000 with the fix and change of backend. Cheers Jake On Thu, 3 Jul 2025 at 11:18=E2=80=AFpm, Jake wro= te: > Continuing: > In `lib/matplotlib/cbook.py`, the function > `_get_running_interactive_framework` has: > > ```text > if not _c_internal_utils.display_is_valid(): > return "headless" > ``` > > In `src/_c_internal_utils.c` we have this docstring for `display_is_valid= `: > > ```text > "Check whether the current X11 or Wayland display is valid.\n\n" > "On Linux, returns True if either $DISPLAY is set and > XOpenDisplay(NULL)\n" > "succeeds, or $WAYLAND_DISPLAY is set and wl_display_connect(NULL)\n= " > "succeeds.\n\n" > "On other platforms, always returns True."}, > ``` > > $DISPLAY is set, so it must be XOpenDisplay(NULL) failing... > > I found a post [1] from a Nix user: > > For anyone else facing similar issues - I resolved this by adding the > X11 library to the LD_LIBRARY_PATH of my development shell. > > But I haven't made any more progress. > > Cheers > Jake > > [1] > https://discourse.nixos.org/t/python-matplotlib-tkinter-matplotlib-revert= s-to-agg-backend-because-it-cant-find-a-valid-display/45064 > > On Thu, Jul 3, 2025 at 1:19=E2=80=AFPM Jake wr= ote: > > > > Hi Lily > > > > It looks like this bug isn't going away anytime soon. > > > > Here is the offending code in `lib/matplotlib/pyplot.py`, with an > > added print statement: > > > > ```text > > # If rcParams['backend_fallback'] is true, and an interactive backend i= s > > # requested, ignore rcParams['backend'] and force selection of a backen= d > that > > # is compatible with the current running interactive framework. > > if (rcParams["backend_fallback"] > > and rcParams._get_backend_or_none() in ( # type: ignore > > set(rcsetup.interactive_bk) - {'WebAgg', 'nbAgg'}) > > and cbook._get_running_interactive_framework()): # type: ignor= e > > print(f"running interactive framework is: > > {cbook._get_running_interactive_framework()}") > > rcParams._set("backend", rcsetup._auto_backend_sentinel) # type: > ignore > > ``` > > > > Running this > > > > ```text > > MPLBACKEND=3Dtkagg guix shell > > --with-source=3Dpython-matplotlib=3D$HOME/matplotlib > > --without-tests=3Dpython-matplotlib python python-matplotlib -- python3 > > -c "import matplotlib; print(matplotlib.get_backend()); import > > matplotlib.pyplot as plt; print(matplotlib.get_backend())" > > ``` > > > > gives > > > > ```text > > TkAgg > > running interactive framework is: headless > > agg > > ``` > > > > So I guess the next question is: why does it think I'm headless? To > > be continued... > > > > Thanks > > Jake > > > > > > On Sat, Apr 5, 2025 at 11:00=E2=80=AFPM Liliana Marie Prikler > > wrote: > > > > > > Hi Jake, > > > > > > Am Donnerstag, dem 03.04.2025 um 11:36 +0000 schrieb Jake: > > > > It appears that importing matplotlib.pyplot resets the Matplotlib > > > > backend to Agg. > > > > > > > > $ guix shell python python-matplotlib -- bash -c 'MPLBACKEND=3Dtk= agg > > > > python3 -c "import matplotlib; print(matplotlib.get_backend()); > > > > import matplotlib.pyplot; print(matplotlib.get_backend())"' > > > > > > > > TkAgg > > > > agg > > > I recently encountered the same issue. The issue is that matplotlib > > > internally sources a configuration file that sets the backend *after* > > > reading the environment variable. To circumvent this, you use > > > something along the lines of the following code until the issue is > > > fixed: > > > > > > from matplotlib import set_backend > > > from os import environ > > > > > > [=E2=80=A6] > > > > > > if __name__ =3D=3D '__main__': > > > if 'MPLBACKEND' in environ: set_backend(environ['MPLBACKEND']) > > > [=E2=80=A6] > > > > > > Cheers > --00000000000014c44b06391603df Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Fixed, I think.=C2=A0 We just need to patch a dlopen call= .

Now TkAgg works out of= the box, without requiring changes to user Python code.=C2=A0 I hope that = also means we can change the default backend from Agg to TkAgg.=C2=A0
=

Submitted this PR (and got lu= cky number 1000!)
with the fix and change of backend.
Cheers
Jake

<= div dir=3D"ltr" class=3D"gmail_attr">On Thu, 3 Jul 2025 at 11:18=E2=80=AFpm= , Jake <jforst.mailman@gmail= .com> wrote:
Continuing:
In `lib/matplotlib/cbook.py`, the function
`_get_running_interactive_framework` has:

```text
=C2=A0 =C2=A0 if not _c_internal_utils.display_is_valid():
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return "headless"
```

In `src/_c_internal_utils.c` we have this docstring for `display_is_valid`:=

```text
=C2=A0 =C2=A0 =C2=A0"Check whether the current X11 or Wayland display = is valid.\n\n"
=C2=A0 =C2=A0 =C2=A0"On Linux, returns True if either $DISPLAY is set = and XOpenDisplay(NULL)\n"
=C2=A0 =C2=A0 =C2=A0"succeeds, or $WAYLAND_DISPLAY is set and wl_displ= ay_connect(NULL)\n"
=C2=A0 =C2=A0 =C2=A0"succeeds.\n\n"
=C2=A0 =C2=A0 =C2=A0"On other platforms, always returns True."},<= br> ```

$DISPLAY is set, so it must be XOpenDisplay(NULL) failing...

I found a post [1] from a Nix user:
> For anyone else facing similar issues - I resolved this by adding the = X11 library to the LD_LIBRARY_PATH of my development shell.

But I haven't made any more progress.

Cheers
Jake

[1] https://discourse.nixos.org/t/python-ma= tplotlib-tkinter-matplotlib-reverts-to-agg-backend-because-it-cant-find-a-v= alid-display/45064

On Thu, Jul 3, 2025 at 1:19=E2=80=AFPM Jake <jforst.mailman@gmail.com> wrote:<= br> >
> Hi Lily
>
> It looks like this bug isn't going away anytime soon.
>
> Here is the offending code in `lib/matplotlib/pyplot.py`, with an
> added print statement:
>
> ```text
> # If rcParams['backend_fallback'] is true, and an interactive = backend is
> # requested, ignore rcParams['backend'] and force selection of= a backend that
> # is compatible with the current running interactive framework.
> if (rcParams["backend_fallback"]
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0and rcParams._get_backend_or_none() i= n (=C2=A0 # type: ignore
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0set(rcsetup.interactive= _bk) - {'WebAgg', 'nbAgg'})
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0and cbook._get_running_interactive_fr= amework()):=C2=A0 # type: ignore
>=C2=A0 =C2=A0 =C2=A0print(f"running interactive framework is:
> {cbook._get_running_interactive_framework()}")
>=C2=A0 =C2=A0 =C2=A0rcParams._set("backend", rcsetup._auto_ba= ckend_sentinel)=C2=A0 # type: ignore
> ```
>
> Running this
>
> ```text
> MPLBACKEND=3Dtkagg guix shell
> --with-source=3Dpython-matplotlib=3D$HOME/matplotlib
> --without-tests=3Dpython-matplotlib python python-matplotlib -- python= 3
> -c "import matplotlib; print(matplotlib.get_backend()); import > matplotlib.pyplot as plt; print(matplotlib.get_backend())"
> ```
>
> gives
>
> ```text
> TkAgg
> running interactive framework is: headless
> agg
> ```
>
> So I guess the next question is: why does it think I'm headless?= =C2=A0 To
> be continued...
>
> Thanks
> Jake
>
>
> On Sat, Apr 5, 2025 at 11:00=E2=80=AFPM Liliana Marie Prikler
> <lil= iana.prikler@gmail.com> wrote:
> >
> > Hi Jake,
> >
> > Am Donnerstag, dem 03.04.2025 um 11:36 +0000 schrieb Jake:
> > > It appears that importing matplotlib.pyplot resets the Matpl= otlib
> > > backend to Agg.
> > >
> > >=C2=A0 =C2=A0$ guix shell python python-matplotlib -- bash -c= 'MPLBACKEND=3Dtkagg
> > > python3 -c "import matplotlib; print(matplotlib.get_bac= kend());
> > > import matplotlib.pyplot; print(matplotlib.get_backend())&qu= ot;'
> > >
> > >=C2=A0 =C2=A0TkAgg
> > >=C2=A0 =C2=A0agg
> > I recently encountered the same issue.=C2=A0 The issue is that ma= tplotlib
> > internally sources a configuration file that sets the backend *af= ter*
> > reading the environment variable.=C2=A0 To circumvent this, you u= se
> > something along the lines of the following code until the issue i= s
> > fixed:
> >
> >=C2=A0 =C2=A0from matplotlib import set_backend
> >=C2=A0 =C2=A0from os import environ
> >
> >=C2=A0 =C2=A0[=E2=80=A6]
> >
> >=C2=A0 =C2=A0if __name__ =3D=3D '__main__':
> >=C2=A0 =C2=A0 =C2=A0if 'MPLBACKEND' in environ: set_backen= d(environ['MPLBACKEND'])
> >=C2=A0 =C2=A0 =C2=A0[=E2=80=A6]
> >
> > Cheers
--00000000000014c44b06391603df--