Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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 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 at 9:55

Your Answer

 
discard

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.