mscroggs.co.uk
mscroggs.co.uk

subscribe

MATH0011: Mathematical Methods II

Installing Python

For the first half of term two, we will be learning to program in Python.
If you have your own laptop, then it would be best to run this term's programming exercises from your own computer. Before you can do this, you will need to install Python. This page will tell you how to install the two components you will need:
  • Python 3 (interpreter) – This will allow you to run Python files.
  • IDLE – This is a text editor that comes with most versions of Python and lets you easily write and run Python files.
In this course we will be using Python 3; please make sure you install the correct version.
If you don't have a laptop, then you will be able to run everything you need on UCL's machines, as these have Python installed.

Windows

If you are using Windows, then Python will not be installed by default. To install Python, carry out the following steps:
  1. Download python.org/ftp/python/3.7.2/python-3.7.2-amd64.exe
  2. Once the file has downloaded, run it, and click through the instructions. The default options are probably fine.
  3. Once the installer has completed, open the start menu and type "IDLE". If IDLE is in the menu, then the installation has worked.
If you have an unusual and/or very old version of Windows, you may need a different installer. You can find these at python.org/downloads/windows/

Mac

Python may be installed by default, but the system version doesn't come with IDLE and may be the wrong version so you'll need to install Python. To do this, carry out the following steps:
  1. Download python.org/ftp/python/3.7.2/python-3.7.2-macosx10.9.pkg
  2. Once the file has downloaded, run it, and click through the instructions. The default options are probably fine.
  3. Once the installer has completed, open Launcher and type "IDLE". If IDLE is there, then the installation has worked.
If you have an unusual and/or very old version of macOS, you may need a different installer. You can find these at python.org/downloads/mac-osx/

Linux

Linux comes with Python, but it doesn't come with IDLE. You can install IDLE by running the following in terminal:
 bash 
sudo apt install idle
You can then launch idle by running the following in terminal:
 bash 
idle

Trying IDLE

Now that you have installed Python and IDLE, you can try running some code. Launch IDLE, then click File → New File.
You will then be faced with two windows: an editor window where you can write your code and a Python shell where your code will run. In the editor window, type:
 python 
print("Hello World")
Then click Run → Run Module. The words "Hello World" should appear in the shell window.

Troubleshooting

If you have any problems installing Python, then you should come to one of the office hours in the first week of the course and I can help you.
© Matthew Scroggs 2019