GNU bug report logs - #55119
27.2; Inferior Python/ M-x run-python problem with Tk on Windows

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Robert Thorpe <rt@HIDDEN>; dated Tue, 26 Apr 2022 04:06:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 55119 <at> debbugs.gnu.org:


Received: (at 55119) by debbugs.gnu.org; 26 Apr 2022 11:14:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 26 07:14:23 2022
Received: from localhost ([127.0.0.1]:37217 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1njJ9D-0003ze-8q
	for submit <at> debbugs.gnu.org; Tue, 26 Apr 2022 07:14:23 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52458)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1njJ9B-0003zK-VV
 for 55119 <at> debbugs.gnu.org; Tue, 26 Apr 2022 07:14:22 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:58004)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1njJ96-0006jC-7l; Tue, 26 Apr 2022 07:14:16 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=PrjdtNdCOeOu/BD6QP4/Oa4yipbDrwbFukzReI2k6uw=; b=sblFvl6gIdc5
 ya7r47GMU0k5byUitx5BithBW472RtLveo5BmLFj3QS4jCJZp5OL1tzdLHVc7vEkgYGXWM/m0MB49
 7K3icGkNvVT/HekFKfgd8im2HjTpvG6rKkh+PLNcSKS44FumuA1FSamNao+vNSEpn820559HmJT0f
 POpa7F+R5Z7119WWIh5QL6lgNzUV/hQ9e4CvFIxYXxHhFcI023PQPYUutsKCm2JUOBMO6uIbRSY1t
 /CBau3KEKGumOpTD3OzDQPD9M0dwMAZRGhQinpUqQS/AwTO/zct65rNIiEDKnvgdUqbZKkelPJFtJ
 IjHogZUz+G/55WTaMgaT5g==;
Received: from [87.69.77.57] (port=3820 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1njJ95-00084z-LD; Tue, 26 Apr 2022 07:14:15 -0400
Date: Tue, 26 Apr 2022 14:14:02 +0300
Message-Id: <83a6c8m70l.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Robert Thorpe <rt@HIDDEN>
In-Reply-To: <87sfq0ebip.fsf@HIDDEN> (message from Robert
 Thorpe on Tue, 26 Apr 2022 05:03:58 +0100)
Subject: Re: bug#55119: 27.2;
 Inferior Python/ M-x run-python problem with Tk on Windows
References: <87sfq0ebip.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 55119
Cc: 55119 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Robert Thorpe <rt@HIDDEN>
> Date: Tue, 26 Apr 2022 05:03:58 +0100
> 
> I have a problem with M-x run-python on Windows 10 enterprise.
> 
> The python code I'm working on uses Tk.  Unfortunately, after Tk is used
> the inferior python no longer responds to inputs.  I see one more
> prompt, then nothing at all.
> 
> Type the following into an inferior python process.  Or alternatively,
> put it in a file and import it.
> 
> import tkinter as tk
> from tkinter import ttk
> window = tk.Tk()
> 
> This pops up a Tk window with nothing in it.  It also gives another
> python prompt.  But after that communication between Emacs and the
> inferior python process seems to be lost.

Unless there's someone here who uses this configuration on Windows,
knows the details, and can dig into the problem, you'll have to tell
more about what the above does, from the technical POV.  It is likely
some snafu with I/O between Emacs and Python when it uses Tcl/Tk, but
what exactly and whether it's at all solvable, is anybody's guess at
this point.  All I can tell you is that Emacs on Windows uses a
bidirectional pipe to communicate with subprocesses, so if the above
fiddles with standard I/O streams in some non-trivial ways, or assumes
it can separate input device from output device, or redirect them
separately to different places, or even that one or both of them are
or can be made unbuffered -- it will simply fail to work on Windows.
You have a single bidirectional pipe which is buffered by the OS, and
at least Python (or any other external program) will see that its
standard I/O is not connected to a console device, and will
(mis)behave accordingly.

The buffering issue you could perhaps deal with, by telling Python to
use unbuffered I/O.  But I'm not even sure this is the root cause of
what you see.

That is all I can tell without more detail, sorry.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#55119; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Apr 2022 04:05:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 26 00:05:38 2022
Received: from localhost ([127.0.0.1]:36571 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1njCSI-0002JF-Cg
	for submit <at> debbugs.gnu.org; Tue, 26 Apr 2022 00:05:38 -0400
Received: from lists.gnu.org ([209.51.188.17]:44432)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rt@HIDDEN>) id 1njCSF-0002J7-Kb
 for submit <at> debbugs.gnu.org; Tue, 26 Apr 2022 00:05:36 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:48784)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rt@HIDDEN>)
 id 1njCSF-0002cy-Ej
 for bug-gnu-emacs@HIDDEN; Tue, 26 Apr 2022 00:05:35 -0400
Received: from outbound-smtp36.blacknight.com ([46.22.139.219]:44451)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rt@HIDDEN>)
 id 1njCSA-0001WR-Jl
 for bug-gnu-emacs@HIDDEN; Tue, 26 Apr 2022 00:05:32 -0400
Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152])
 by outbound-smtp36.blacknight.com (Postfix) with ESMTPS id 500D422C4
 for <bug-gnu-emacs@HIDDEN>; Tue, 26 Apr 2022 05:05:26 +0100 (IST)
Received: (qmail 31332 invoked from network); 26 Apr 2022 04:05:26 -0000
Received: from unknown (HELO rt-inspiron-3480)
 (rt@HIDDEN@[109.78.29.216])
 by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated);
 26 Apr 2022 04:05:26 -0000
From: Robert Thorpe <rt@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 27.2; Inferior Python/ M-x run-python problem with Tk on Windows
Date: Tue, 26 Apr 2022 05:03:58 +0100
Message-ID: <87sfq0ebip.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=46.22.139.219;
 envelope-from=rt@HIDDEN;
 helo=outbound-smtp36.blacknight.com
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)


I have a problem with M-x run-python on Windows 10 enterprise.

The python code I'm working on uses Tk.  Unfortunately, after Tk is used
the inferior python no longer responds to inputs.  I see one more
prompt, then nothing at all.

Type the following into an inferior python process.  Or alternatively,
put it in a file and import it.

import tkinter as tk
from tkinter import ttk
window = tk.Tk()

This pops up a Tk window with nothing in it.  It also gives another
python prompt.  But after that communication between Emacs and the
inferior python process seems to be lost.

It seems that someone had the same problem 20 years ago.  I can't find
anyone having this problem recently though.
https://python-list.python.narkive.com/miSHgA8U/problems-with-tkinter-based-scripts-under-emacs

If it helps I'm using Python 3.9.11 64-bit and Tcl/Tk 8.6.

(I am sending this from Emacs 27.2 on Arch but I've copied over the
debug text below from the PC with the issue).

BR,
Robert Thorpe


In GNU Emacs 28.1 (build 52, x86_64-w64-mingw32)
 of 2022-04-04 built on AVALON
Repository revision: 5a223c7f2ef4c31abbd46367b6ea83cd19d30aa7
Repository branch: heads/emacs-28.1
Windowing system distributor 'Microsoft Corp.', version 10.0.19042
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19042.1586)

Configured using:
 'configure --without-dbus --with-native-compilation
 --without-compress-install CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
XPM ZLIB

(NATIVE_COMP present but libgccjit not available)

Important settings:
  value of $LANG: ENI
  locale-coding-system: cp1252

Major mode: Inferior Python

Minor modes in effect:
  compilation-shell-minor-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
mule-util compile text-property-search python tramp-sh tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat shell
pcomplete parse-time iso8601 time-date format-spec auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
comint ring ansi-color cl-extra seq byte-opt gv bytecomp byte-compile
cconv help-mode novice dired-aux cl-loaddefs cl-lib dired dired-loaddefs
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 79959 6409)
 (symbols 48 9143 1)
 (strings 32 29136 1864)
 (string-bytes 1 996338)
 (vectors 16 18266)
 (vector-slots 8 255188 8970)
 (floats 8 46 170)
 (intervals 56 562 0)
 (buffers 992 17))




Acknowledgement sent to Robert Thorpe <rt@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#55119; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 26 Apr 2022 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.