October 23, 2024
Chicago 12, Melborne City, USA
python

Output from evaluating python source code blocks in org-mode not correct


After switching to Mac from Windows, the output of my python org-mode code blocks are not working properly. It keeps printing what seems to be the backend python call, and not even the full command, seems to cut the command short (as in the example below the Result stops before the input to the python "print" command).

The code is executing as expected and the results are printed in the interactive python session buffer (still with the annoying backend call at the top though). However, it is not being appended in the org-mode buffer itself. Any tips on how to

  1. Output the actual python outputs in the org-mode buffer
  2. not output the "__PYTHON_EL_eva(…)" part

Here is example code:

#+BEGIN_SRC python :python python3 :session py :results output  :noweb yes :tangle no

print("Somehow the output of these source blocks are not displayed correctly? I did not have this issue with emacs on Windows...")

#+END_SRC
#+RESULTS:
: __PYTHON_EL_eval("try:\n    with open('/var/folders/ty/x6hl83sn5cz667zpq3yk02lr0000gn/T/babel-PJfJby/python-HFmx85') 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('

This is how it looks in the interactive python buffer:

__PYTHON_EL_eval_file("/var/folders/ty/x6hl83sn5cz667zpq3yk02lr0000gn/T/py66QmoC", "/var/folders/ty/x6hl83sn5cz667zpq3yk02lr0000gn/T/py66QmoC", True)
Somehow the output of these source blocks are not displayed correctly? I did not have this issue with emacs on Windows...
org_babel_python_eoe
>>> 

Running Emacs 29.4 on macOS Sonoma 14.4

I have tried to set :results value which returns "None" as expected. I notice this does not print the backend string.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video