Since different python version installed on my system, how can I use specific python and option to run it?

For example,below test.py file will print hello output.

#!/opt/anaconda3/bin/python --myoptions

I want to get a equivalent by org-babel, maybe something like below:

#+BEGIN_SRC python :results :cmd /opt/anaconda3/bin/python :option --myoptions

Do we have such option to config that?


In Org 9.2.3 function org-babel-execute:python contains following let-assignment:

      (or (cdr (assq :python params))

Therefore, the header argument you are looking for is (at least in that Org version):

:python /opt/anaconda3/bin/python --myoptions

Those lines have been introduced in Org at commit e527e49c38.

Note, that those lines are also part of the newest release on 2019-12-27, i.e., Org 9.3.1.

  • Alternatively, the variable can be customized once and for all to the desired value. That way, you don't have to specify it for each code block.
    – NickD
    Dec 27 '19 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.