3
#+begin_src python :session :results output
print("yes")
#+end_src

With org-babel-execute-src-block command, the result is:

#+RESULTS:
: __PYTHON_EL_eval("try:\n    with open('/var/folders/hh/lnftkrwn1tv9b63ptnphj_gm0000gp/T/babel-ww4KL0/python-AICyg8') as __org_babel_python_tmpfile:\n        exec(compile(__org_babel_python_tmpfile.read(), __org_babel_python_tmpfile.name, 'exec'))\nexcept:\n    raise\nfinally:\n    print('

not "yes".

:results value is behaved as expected.

Error message:

error in process filter: sort: Wrong type argument: stringp, (\, "python")
error in process filter: Wrong type argument: stringp, (\, "python")
Can’t guess python-indent-offset, using defaults: 4

Version:

GNU Emacs 28.1 (build 1, x86_64-apple-darwin19.6.0, Carbon Version 162 AppKit 1894.6)
 of 2022-04-28
org mode 9.5.3

Update: I find the error gone when I use python 3.9 instead of python 3.7. I do not understand the link between the issue and version of python, but it does fix the issue.

Tokubara
  • 177
  • 5

1 Answers1

0

I came to this question seeing the same error. Eventually I discovered how python sessions use buffers and how to inspect what went wrong from this answer.

If you don't specify a :session name, the default buffer is named *Python*. To continue using that session you can:

  • switch to the buffer and inspect what may have gone wrong before this block was called and fix it up,
  • call reset on the first line of the block, or
  • use a new session name.

There may be other workarounds, including killing the session buffer.

I expect this would work on first try:

#+begin_src python :session xyzzy :results output
print("yes")
#+end_src

Unfortunately I've been unable to replicate the error since resolving it, but that would be helpful if this is considered a bug to fix.

stokes
  • 23
  • 5