Running Python from home

Getting Python to run on your computer at home is strongly encouraged, since it allows you to experiment with Python in your own time. Follow these instructions to install Python and IDLE, the Python editor:

On Windows

  1. Go to the Python download page.
  2. Click on the "Windows installer" link. This will download a .msi file, which you should run.
  3. Follow the instructions to install Python. You should not need to modify any of the defaults.
  4. Once it has installed, go to your start menu and look under Python. You should find a number of entries, including IDLE, the Python editor.

On Mac OS X

The OS X installer for Python is a Universal Binary (so it will run on both Intel Macs and the older PowerPC-based models). The installer is available from the same download page as the Windows version.

On Linux

The Linux downloads on the Python download page are the source code, which you will need to compile yourself. To save his hassle, you can use your Linux distribution's package manager (e.g. Synaptic on Ubuntu, YaST on SUSE, RPM on Fedora etc.) to install precompiled packages

  • python2.5 (Python itself)
  • python2.5-doc (the Python help files which can be accessed from within the program)
  • idle-python2.5 (the IDLE editor)

Other packages may be required (dependencies) however your package manager will automatically select these for you. Remember that, as on other systems, IDLE is not entirely stable and can require restarting. The default text editors in the GNOME and KDE desktops (gedit and Kate respectively) include Python syntax highlighting, and files saved as .py can then be double-clicked to run them.

Quick install (Ubuntu)

You can install the required packages more quickly in Ubuntu by copy-pasting the following commands into a Terminal. Note that control + v does not work, you must use Edit —> Paste. Note also that you will be required to enter your password to do this.

sudo apt-get install python-2.5
sudo apt-get install python-2.5-docs
sudo apt-get install idle

PS: A similar process is possible in other Linux distributions - see your distribution's documentation page (or community wiki!) for details.

A word on IDLE

IDLE is an Integrated Development Environment (IDE) that comes free with Python. It provides a number of basic program editing features, such as colouring your source code for you, and allows you to run and view your Python programs.

Don't double-click on a Python (.py) file icon to open/edit it. This can be a hard habit to get out of. If you do this, the system runs the program immediately, but this will not allow you to look at any error messages (and often program output) that your program produces. Also right-click followed by Open With… doesn't work well either.

Instead, to open/edit a program file, you should always start up IDLE and open the file using File/Open… in order to examine it. Note also the File/Recent Files> option which is a quick way of opening files you've worked with before.

IDLE is not always reliable, and will sometimes need to be restarted. It will also get easily confused if you run more than one copy of IDLE at the same time. However, despite its faults, editing through an IDE like IDLE is the best way to start learning programming, and you should get into the habit of using IDLE to run and edit your programs.

Programming on computers without Python

If you are at a computer which does not have Python installed (e.g. one on the main university network) you can still create Python files - although obviously not run or test them. Simply enter your code in a text editor (such as Notepad or Notepad++ - not a word processor such as Microsoft Word or Wordpad) and then save it as a .py file (remember to email it or put it on a USB key!) When you next log on to a computer with Python installed, you can open these files in IDLE the same as if they had been created on a machine with a Python installation.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License