Massachusetts Institute of Technology
Dept. of Electrical Engineering and Computer Science
Spring Semester, 2008
6.01: Introduction to EECS I

Installing Python for Emacs

These steps are necessary only if you are using Emacs 21 or earlier. For Emacs 22, Python support is built in.

A. Download the necessary files

Download the following to your home directory: python-mode.el.

B. Changing the configuration file for emacs

Edit your .emacs file in your home directory to include the following:

(load "~/python-mode.el")
;;python
(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist (cons '("python" . python-mode)
				   interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode." t)
(global-font-lock-mode t)
(font-lock-mode +1)

C. Check that Python mode works

Create a new file that ends in ".py". If you see Python by your file name, then your installation should be working. If you have any problems installing python using these instructions, please ask the staff for help.