* bug#29592: 25.3; python does not print input or output in the inferior process
@ 2017-12-06 18:59 Alex Branham
2017-12-12 23:28 ` Noam Postavsky
2022-02-25 21:57 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 2 replies; 7+ messages in thread
From: Alex Branham @ 2017-12-06 18:59 UTC (permalink / raw)
To: 29592
In python-mode (from python.el), writing
import pandas as pd
pd.Series([1, 2, 3, 4, 5])
after starting an inferior python process, selecting the buffer, and
running M-x python-shell-send-region no output is printed in the process
buffer even though the statements are evaluated.
If you manually type pd.Series([1, 2, 3, 4, 5]) into the python process
buffer, it prints
0 1
1 2
2 3
3 4
dtype: int64
I think ideally, Emacs should show that the statements are sent to the interpreter by printing them and also show their output so running python-shell-send-region from above would leave the inferior process buffer looking something like:
>>> import pandas as pd
>>> pd.Series([1, 2, 3, 4, 5])
0 1
1 2
2 3
3 4
4 5
dtype: int64
>>>
In GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.19)
of 2017-09-16 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
-fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#29592: 25.3; python does not print input or output in the inferior process
2017-12-06 18:59 bug#29592: 25.3; python does not print input or output in the inferior process Alex Branham
@ 2017-12-12 23:28 ` Noam Postavsky
2022-02-25 21:57 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 0 replies; 7+ messages in thread
From: Noam Postavsky @ 2017-12-12 23:28 UTC (permalink / raw)
To: Alex Branham; +Cc: 29592
severity 29592 wishlist
quit
Alex Branham <alex.branham@gmail.com> writes:
> In python-mode (from python.el), writing
>
> import pandas as pd
> pd.Series([1, 2, 3, 4, 5])
>
> after starting an inferior python process, selecting the buffer, and
> running M-x python-shell-send-region no output is printed in the process
> buffer even though the statements are evaluated.
>
> If you manually type pd.Series([1, 2, 3, 4, 5]) into the python process
> buffer, it prints
>
> 0 1
> 1 2
> 2 3
> 3 4
> dtype: int64
>
> I think ideally, Emacs should show that the statements are sent to the
> interpreter by printing them and also show their output so running
> python-shell-send-region from above would leave the inferior process
> buffer looking something like:
>
>>>> import pandas as pd
>>>> pd.Series([1, 2, 3, 4, 5])
> 0 1
> 1 2
> 2 3
> 3 4
> 4 5
> dtype: int64
>>>>
python-shell-send-region works by saving to a temp file, and loading
that. I think sending each statement separately should be a separate
command.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#29592: 25.3; python does not print input or output in the inferior process
2017-12-06 18:59 bug#29592: 25.3; python does not print input or output in the inferior process Alex Branham
2017-12-12 23:28 ` Noam Postavsky
@ 2022-02-25 21:57 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-25 23:00 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-26 16:26 ` Augusto Stoffel
1 sibling, 2 replies; 7+ messages in thread
From: Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-25 21:57 UTC (permalink / raw)
To: Alex Branham; +Cc: 29592
On Wed, 06 Dec 2017, Alex Branham wrote:
> In python-mode (from python.el), writing
>
> import pandas as pd
> pd.Series([1, 2, 3, 4, 5])
>
> after starting an inferior python process, selecting the buffer, and
> running M-x python-shell-send-region no output is printed in the process
> buffer even though the statements are evaluated.
I found that Python REPL output is displayed only if the python code is
on the first line of the buffer. Is this the same for you Alex?
For example, running `emacs -q`, I open /tmp/foo.py, and M-x run-python
(C-c C-p) to open the Python REPL. Then I switch focus back to the
foo.py buffer and enter 'abc' on the first line, including quotes. I run
M-x python-shell-send-statement (C-c C-e), Emacs says 'Sent: "abc"...'
and '>>> abc\n' is displayed in the REPL. If I add a newline before
'abc' and repeat, it says 'Sent: "abc"' and only ">>> " is printed to
the REPL.
Same issue when using M-x python-shell-send-region (C-c C-r) and
explicitly highlighting the 'abc' when it's not the first line in the
buffer.
I'm using GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.30, cairo version 1.16.0). Windowing system distributor 'The X.Org
Foundation', version 11.0.12101002. System Description: Guix System
Regards,
Ben
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#29592: 25.3; python does not print input or output in the inferior process
2022-02-25 21:57 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-25 23:00 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-26 16:26 ` Augusto Stoffel
1 sibling, 0 replies; 7+ messages in thread
From: Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-25 23:00 UTC (permalink / raw)
To: Alex Branham; +Cc: 29592
The GitHub ticket below for elpy also mentions this issue and includes some
"quick-and-dirty" that does seem to address the issue. The code works,
but I get an extra line break in the REPL when evaluating lines other
than the first line of the buffer.
https://github.com/jorgenschaefer/elpy/issues/924#issuecomment-314922197
> This is not an elpy issue, it also occurs with plain python-mode. It
> seems to be caused by certain versions of Python only. A quick-and-dirty
> fix is (in .emacs):
>
> (defun python-shell-append-to-output (string)
> (let ((buffer (current-buffer)))
> (set-buffer (process-buffer (python-shell-get-process)))
> (let ((oldpoint (point)))
> (goto-char (process-mark (python-shell-get-process)))
> (insert string)
> (set-marker (process-mark (python-shell-get-process)) (point))
> (goto-char oldpoint))
> (set-buffer buffer)))
>
> (defadvice python-shell-send-string
> (around advice-python-shell-send-string activate)
> (interactive)
> (let* ((append-string1
> (if (string-match "import codecs, os;__pyfile = codecs.open.*$" string)
> (replace-match "" nil nil string)
> string))
> (append-string2
> (if (string-match "^# -\\*- coding: utf-8 -\\*-\n*$" append-string1)
> (replace-match "" nil nil append-string1)
> append-string1))
> (append-string
> (if (string-match "^\n*$" append-string2)
> (replace-match "" nil nil append-string2)
> append-string2)))
> (python-shell-append-to-output
> (concat (string-trim-right append-string) "\n")))
> (if (called-interactively-p 'any)
> (call-interactively (ad-get-orig-definition 'python-shell-send-string))
> ad-do-it))
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#29592: 25.3; python does not print input or output in the inferior process
2022-02-25 21:57 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-25 23:00 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-02-26 16:26 ` Augusto Stoffel
2022-02-27 12:58 ` Lars Ingebrigtsen
2022-02-27 22:58 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 2 replies; 7+ messages in thread
From: Augusto Stoffel @ 2022-02-26 16:26 UTC (permalink / raw)
To: 29592; +Cc: alex.branham, ben
On Sat, 26 Feb 2022 at 08:57, Ben Sturmfels via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> wrote:
> On Wed, 06 Dec 2017, Alex Branham wrote:
>
>> In python-mode (from python.el), writing
>>
>> import pandas as pd
>> pd.Series([1, 2, 3, 4, 5])
>>
>> after starting an inferior python process, selecting the buffer, and
>> running M-x python-shell-send-region no output is printed in the process
>> buffer even though the statements are evaluated.
>
> I found that Python REPL output is displayed only if the python code is
> on the first line of the buffer. Is this the same for you Alex?
>
> For example, running `emacs -q`, I open /tmp/foo.py, and M-x run-python
> (C-c C-p) to open the Python REPL. Then I switch focus back to the
> foo.py buffer and enter 'abc' on the first line, including quotes. I run
> M-x python-shell-send-statement (C-c C-e), Emacs says 'Sent: "abc"...'
> and '>>> abc\n' is displayed in the REPL. If I add a newline before
> 'abc' and repeat, it says 'Sent: "abc"' and only ">>> " is printed to
> the REPL.
>
> Same issue when using M-x python-shell-send-region (C-c C-r) and
> explicitly highlighting the 'abc' when it's not the first line in the
> buffer.
>
> I'm using GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
> 3.24.30, cairo version 1.16.0). Windowing system distributor 'The X.Org
> Foundation', version 11.0.12101002. System Description: Guix System
This was fixed in Emacs 28.
> Regards,
> Ben
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#29592: 25.3; python does not print input or output in the inferior process
2022-02-26 16:26 ` Augusto Stoffel
@ 2022-02-27 12:58 ` Lars Ingebrigtsen
2022-02-27 22:58 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-02-27 12:58 UTC (permalink / raw)
To: Augusto Stoffel; +Cc: alex.branham, ben, 29592
Augusto Stoffel <arstoffel@gmail.com> writes:
>> I'm using GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
>> 3.24.30, cairo version 1.16.0). Windowing system distributor 'The X.Org
>> Foundation', version 11.0.12101002. System Description: Guix System
>
> This was fixed in Emacs 28.
OK; I'm closing this bug report, then.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#29592: 25.3; python does not print input or output in the inferior process
2022-02-26 16:26 ` Augusto Stoffel
2022-02-27 12:58 ` Lars Ingebrigtsen
@ 2022-02-27 22:58 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 0 replies; 7+ messages in thread
From: Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-02-27 22:58 UTC (permalink / raw)
To: Augusto Stoffel; +Cc: alex.branham, 29592
On Sat, 26 Feb 2022, Augusto Stoffel wrote:
> On Sat, 26 Feb 2022 at 08:57, Ben Sturmfels wrote:
>
>> I'm using GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
>> 3.24.30, cairo version 1.16.0). Windowing system distributor 'The X.Org
>> Foundation', version 11.0.12101002. System Description: Guix System
>
> This was fixed in Emacs 28.
Thanks so much Augusto! I've just built Emacs 28.0.91 and can confirm
that the python-shell-send-statement output is showing in the REPL. :)
Regards,
Ben
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-02-27 22:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-06 18:59 bug#29592: 25.3; python does not print input or output in the inferior process Alex Branham
2017-12-12 23:28 ` Noam Postavsky
2022-02-25 21:57 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-25 23:00 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-26 16:26 ` Augusto Stoffel
2022-02-27 12:58 ` Lars Ingebrigtsen
2022-02-27 22:58 ` Ben Sturmfels via Bug reports for GNU Emacs, the Swiss army knife of text editors
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.