When I C-c C-c
in a Python code block in Org mode:
#+BEGIN_SRC python :results value :session
a = 4
a + 13
#+END_SRC
It hangs with a message:
Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support readline, yet ‘python-shell-completion-native-enable’ was t and "python" is not part of the ‘python-shell-completion-native-disabled-interpreters’ list. Native completions have been disabled locally. Disable showing Disable logging
It can be reproduced with emacs -Q
with
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)))
I tried to debug this using M-x toggle-debug-on-quit
:
Debugger entered--Lisp error: (quit)
accept-process-output(#<process Python>)
org-babel-python--send-string("*Python*" "import ast\nwith open('/var/folders/78/44lg7sv17db2...")
org-babel-python-evaluate-session("*Python*" "a = 4\na + 13" value ("replace" "value"))
org-babel-python-evaluate("*Python*" "a = 4\na + 13" value ("replace" "value") nil nil)
org-babel-execute:python("a = 4\na + 13" ((:colname-names) (:rowname-names) (:result-params "replace" "value") (:result-type . value) (:results . "replace value") (:exports . "code") (:cache . "no") (:noweb . "no") (:hlines . "no") (:tangle . "no") (:session)))
org-babel-execute-src-block(nil ("python" "a = 4\na + 13" ((:colname-names) (:rowname-names) (:result-params "value" "replace") (:result-type . value) (:results . "value replace") (:exports . "code") (:session) (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no")) "" nil 148 "(ref:%s)"))
org-ctrl-c-ctrl-c(nil)
funcall-interactively(org-ctrl-c-ctrl-c nil)
call-interactively(org-ctrl-c-ctrl-c nil nil)
command-execute(org-ctrl-c-ctrl-c)
but I'm new to emacs (started a week ago) and cannot extract any useful info from this log.
I thought perhaps this post is relevant, but it did not solve the issue.
Interestingly, when I do C-c C-c
after manually starting the Python REPL via M-x run-python
, it runs smoothly without any error or warning messages.
I'm using Emacs 28.1 in macOS 12.4 (using the Emacs plus distribution for macOS, if relevant). Python 3.10.0 is managed by Pyenv, which is installed via Homebrew. eshell correctly finds the installed Python.
Thanks in advance.
Update
org-babel-python-command
is "python"
.
When I M-x run-python
, it runs Python 3.10.0.