14

On: Aquamacs 3.3 GNU Emacs 25.1.1 (x86_64-apple-darwin14.1.0, NS appkit-1344.72 Version 10.10.2 (Build 14C109)) of 2016-09-19 in mac osx sierra

I changed my ~/Library/Preferences/Aquamacs Emacs/Preferences.el with the below:

(setq python-version-checked t)
(setq py-python-command "python3.5")

(eval-after-load "org"
  '(org-babel-do-load-languages
    'org-babel-load-languages
    '((sh . t)
      (python . t)
      (emacs-lisp . t)
      (ditaa . t))))

but it still fails to point to python 3.5. Thanks!

1 Answer 1

17

I discovered that just setting in the file: ~/Library/Preferences/Aquamacs Emacs/Preferences.el

(setq org-babel-python-command "python3")

Does the job. However, i don't really understand why it worked here and not in the ob-python.el file directly. If anyone has a view, please share.

4
  • What do you mean by "here" vs "in the ob-python.el file directly"?
    – Basil
    Commented May 26, 2017 at 9:43
  • This solution also works if the line is added to .emacs.el or .emacs.d/init.el
    – Frank M
    Commented Jul 24, 2018 at 19:09
  • 1
    It may be safer and more flexible to add this in a file variable. You may end up using python3 while wanting/thinking/needing python2. Using M-x add-file-local-variable, then selecting org-babel-python-command and setting it to "python3" (notice the quotes), it changes the variable only for the current file. You need to revert the buffer. You may also need to validate this local change of variable. You can check the python version by importing the sys module and printing the version print(sys.version).
    – Lalylulelo
    Commented Apr 24, 2019 at 9:27
  • 1
    I use (setq org-babel-python-command "py -3.9") to use Python 3.9, taking advantage of the pylauncher. Each time I need Python 3.7, I just change 3.9 to 3.7 in the command.
    – kotchwane
    Commented Mar 31, 2021 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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