according to the contents of python.el (the source file of python mode) run-python's cmd
defaults to a function which returns the path and parameters of the system's default python version, and in turn runs this via python-shell-make-comint
, so simply setting an unquoted name (a nonexistant variable as ELisp sees it) or trying to run a shell command directly won't work.
What works, however, is M-: (run-python "python3")
, using double quotes in comparison to your first variant. It opens a new buffer with a python prompt, but does not necessarily get it to the front (ie., use C-x C-b
and select the python buffer from the list). You can see that it worked if „Shell native completion is enabled” appears in the status line.
Depending on which python version you usually run, it is even easier to set it in your ~/.emacs.d/init.el
and run it via C-c C-p
, or to add those two variables as file-locals in a comment block at the end of a python file (excerpt from python.el's header):
;; … . You can change
;; your default interpreter and commandline arguments by setting the
;; `python-shell-interpreter' and `python-shell-interpreter-args'
;; variables. This example enables IPython globally:
;; (setq python-shell-interpreter "ipython"
;; python-shell-interpreter-args "-i")
;; … . You can change
;; your default interpreter and commandline arguments by setting the
;; `python-shell-interpreter' and `python-shell-interpreter-args'
;; variables. This example enables IPython globally:
;; (setq python-shell-interpreter "ipython"
;; python-shell-interpreter-args "-i")