Python 3 shell in Emacs

If you’d like to run a Python 3 shell within Emacs you could issue the following command:

C-u M-x run-python

It’ll then prompt you to confirm which Python version you’d want to run. You can just type 3 and click Enter again. If you use it a lot, however, it’s not going to be the most convenient of the solutions. You could automate the whole process by adding the following 2 lines to your ~/.emacs file:

(defun run-python3 () (interactive) (run-python "python3"))
(global-set-key [f5] 'run-python3)

The second line assigns a keybinding to the command. In the example above it is the F5 key.

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>