Reputation: 14065
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
python
so that it points to python3
instead of python2.7
(because that might cause various bad things)"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.
Upvotes: 3
Views: 371
Reputation: 1782
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.
Upvotes: 4
Reputation: 20757
You can use the shebang line to specify which version you want to run:
#!/usr/bin/env python
Will use whichever one the system considers "python"
#!/usr/bin/env python2.6
#!/usr/bin/env python2.7
#!/usr/bin/env python3.2
Will run the specified version if you have more than one installed.
A friend taught me this when our Ops guy set up a VM with 2.6 and 2.7 installed, and I required 2.7, while the CentOS package manager required 2.6. Saved me a lot of having to go back and make things 2.6-compatible.
Upvotes: 0