13

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!

kotchwane
  • 481
  • 2
  • 12
Cy Bu
  • 481
  • 4
  • 14

1 Answers1

16

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.

Cy Bu
  • 481
  • 4
  • 14
  • What do you mean by "here" vs "in the `ob-python.el` file directly"? – Basil May 26 '17 at 09:43
  • This solution also works if the line is added to .emacs.el or .emacs.d/init.el – Frank M Jul 24 '18 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 Apr 24 '19 at 09:27
  • 1
    I use `(setq org-babel-python-command "py -3.9")` to use Python 3.9, taking advantage of the [pylauncher](https://stackoverflow.com/questions/4583367/how-to-run-multiple-python-versions-on-windows/13211456#13211456). Each time I need Python 3.7, I just change 3.9 to 3.7 in the command. – kotchwane Mar 31 '21 at 15:15