I have the following settings on for org-babel
#+PROPERTY: header-args:python :python ~/env/pt/bin/python :session a :results drawer output replace
When I evaluate a code block, the results are some long command string
#+begin_src python
print(2)
#+end_src
#+RESULTS:
:results:
__PYTHON_EL_eval("try:\n with open('/var/folders/rv/z9fg34554pv9zbn9grgcpv2m0000gn/T/babel-luDzsI/python-cj3oCx') 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('
:end:
If I go into the Python inferior, I find that indeed, the commands being sent to it are this weird stuff.
>>>
__PYTHON_EL_eval("try:\n with open('/var/folders/rv/z9fg34554pv9zbn9grgcpv2m0000gn/T/babel-luDzsI/python-yTGDdP') 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('org_babel_python_eoe')", "<string>")
2
org_babel_python_eoe
>>>
__PYTHON_EL_eval("try:\n with open('/var/folders/rv/z9fg34554pv9zbn9grgcpv2m0000gn/T/babel-luDzsI/python-cj3oCx') 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('org_babel_python_eoe')", "<string>")
2
org_babel_python_eoe
If I enter commands into the inferior directly it works fine (though it annoyingly echoes all the commands first).
If I don't use a session it works fine.
I have
- Org mode version 9.6.15
- Python 3.11.9
- GNU Emacs 29.2 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2024-01-18
~/env/pt/bin/python
, but when I replace that with/usr/bin/python3
, it all works for me. Org mode version 9.8-pre (release_9.7.6-81-gd6c0bb), python version 3.12.3.