I have been unable to get my Aquamacs 3.5 (built on Gnu Emacs to run Python 3. I have put the following lines in both my Preferences.el (the Mac equivalent of .emacs) and within an explicit .emacs without success. However, I do get Python 3 when I run straight GNU emacs 27.1 both from the Command Line and using the MacPorts Emacs.app.

(setq python-shell-interpreter
(setq py-python-command "/Users/pcolsen/opt/anaconda3/bin/python3")
(add-hook 'python-mode-hook
      #'(lambda () (setq py-python-command "/Users/pcolsen/opt/anaconda3/bin/python3")))
(add-hook 'python-mode-hook
      #'(lambda () (setq python-shell-interpreter "/Users/pcolsen/opt/anaconda3/bin/python3")))

I have also set the environment variable PYTHON to

export PYTHON="/Users/pcolsen/opt/anaconda3/bin/python3"

Despite all of this, my Aquamacs persists in running Python 2.7. Is there anything else I can do?

The specific version of Aquamacs is Aquamacs 3.5 GNU Emacs (x86_64-apple-darwin16.7.0, NS appkit-1504.83 Version 10.12.6 (Build 16G2016)) dated 2019-08-18 rev.

2 Answers 2


I'm not sure I have an answer, but I may have a clue.

There are actually two emacs packages that provide python support. One is provided by GNU, and lives in a file called python.el; one is not part of GNU (copyright issues, apparently) and lives in a file called python-mode.el.

Aquamacs provides both:[*]

  • The non-gnu one: /Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/edit-modes/python-mode/python-mode.el
  • The gnu one: /Applications/Aquamacs.app/Contents/Resources/lisp/progmodes/python.el

I imagine GNU emacs 27.1 provides only the GNU one. They are actually very different -- e.g. their menus look very different, but confusingly, they both provide a a python-mode.

I see you have tried to cover both bases by setting both:

  • python-shell-interpreter (the gnu variable)
  • py-shell-name (the non-gnu variable)

But guess is that there is some interference between the two.

You don't say what command you are using to start up the python interpreter, but if you use 'py-shell' you will be using the code from the non-gnu version, and you should get the version of python you have set in py-python-command.

[I'm using Aquamacs -- same version as you, and I tried to avoid complications by using only the gnu version, but non-gnu version seemed to always creep in -- it is perhaps higher up the load path, so I have settled on using only the non-gnu version].

[*] and actually it provides a third one, wisent python : /Applications/Aquamacs.app/Contents/Resources/lisp/cedet/semantic/wisent/python.el.gz -- I have avoided looking at this


I think if you put both of these lines in ~/Library/Preferences/Aquamacs Emacs/Preferences.el, it does the right thing:

(setq python-shell-interpreter "/usr/bin/python3")
(setq py-shell-name "/usr/bin/python3")

(or whatever your path is)

And then either M-x run-python or C-c C-c will both work. As I'm sure you figured out sometime in 2021, but I'm extremely grateful that now I could fix this, too.

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.