Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate output in Jupyter console when calling external executables using the subprocess module #2042

Open
bastro3000 opened this issue Apr 20, 2024 · 0 comments

Comments

@bastro3000
Copy link

Summary

Duplicate output in Jupyter console when calling external executables using the subprocess module

Steps to reproduce

  1. Open Emacs (GUI or Console mode)
  2. Open any .py file to enter Elpy mode
  3. Make sure the python shell interpreter is set to Jupyter (see Elpy configuration)
  4. Open an Elpy console window (C-x C-z)
  5. Execute the following Python code from the Elpy console window:
import subprocess
subprocess.call('/bin/pwd')

Result: The current working directory is printed twice in the console.

The same happens with the standard output of any executable and if a call to subprocess.call is done while executing any python code from Emacs (e.g. using C-c C-c).

This doesn't occur when using the standard Python console.

My configuration

OS

Ubuntu
Release 23.10 (Mantic Minotaur) 64-bit
Kernel Linux 6.5.0-28-generic x86_64
MATE 1.26.2

Result of (elpy-config)

Elpy Configuration

Emacs.............: 29.3
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: jupyter ... (/home/sebastien/anaconda3/bin/jupyter)
RPC virtualenv....: rpc-venv (/home/sebastien/.emacs.d/elpy/rpc-venv)
 Python...........: python 3.10.13 (/home/sebastien/.emacs.d/elpy/rpc-venv/bin/python)
 Jedi.............: 0.19.1
 Autopep8.........: 2.0.4 (2.1.0 available)
 Yapf.............: 0.40.2
 Black............: 23.11.0 (24.4.0 available)
Syntax checker....: flake8 (/home/sebastien/anaconda3/bin/flake8)

Elpy configuration in my init.el

;; Enable elpy
(elpy-enable)

;; Use IPython for REPL
(setq python-shell-interpreter "jupyter"
      python-shell-interpreter-args "console --simple-prompt"
      python-shell-prompt-detect-failure-warning nil)
(add-to-list
 'python-shell-completion-native-disabled-interpreters
 "jupyter")

;; Enable flycheck
(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

;; Disable mypy
(add-hook
 'elpy-mode-hook
 (lambda ()
   (add-to-list
    'flycheck-disabled-checkers
    'python-mypy)))

;; Enable autopep8
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-mode)

;; Don't print code sent to ipython
(setq elpy-shell-echo-input nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant