Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using emacs in python mode.

To run a python file I use the command C-c C-c.

Emacs automatically start to run python 2.7 while I would like to use python3.

Once I have been able to solve using this method link but now it is not working on ubuntu 14.04

How can I solve this?

share|improve this question

Here's a solution which re-defines python-shell-parse-command:

(require 'python)
(defun python-shell-parse-command ()
  "Return the string used to execute the inferior Python process."
  "/usr/bin/python3 -i"

Calling run-python invokes /usr/bin/python3 -i.

As a side note

There are two modes for python: python.el (default) and python-mode.el. You cite binding from python.el so I gave a solution for python.el. I just wanted to mention that python-mode.el has a built-in command for the task: python3.

share|improve this answer
I am not totally sure that I am using python.el hoe can n i checkthis? – Donbeo May 8 '14 at 17:29
This works partially. Now when I use C-c C-c it runs the script on python3. The command C-c | used to evaluate only the lightened region does not work anymore – Donbeo May 9 '14 at 9:55

Setting (setq python-shell-interpreter "python3") in .emacs should be enough

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.