Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the default command for `run-python`?

I'm starting on a Python 3 project, so I'd like to configure Emacs' run-python command to use the python3 interpreter by default.

I don't want to

  • change python so that it points to python3 instead of python2.7 (because that might cause various bad things)
  • pass "python3" as an argument to the run-python command each time I run it (because that sounds annoying)

I've tried setting python-which-shell to "python3" in my .emacs, but this doesn't seem to work.

like image 421
Inaimathi Avatar asked Jun 19 '26 09:06

Inaimathi


1 Answers

On Emacs 24.3, add to your .emacs:

(setq python-shell-interpreter "python3")

If this doesn't work on an older Emacs with a different Python mode, try M-x find-function RET run-python RET to inspect the source for an equivalent variable that can be set.

like image 197
Dan Jacka Avatar answered Jun 20 '26 22:06

Dan Jacka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!